Answer the question
In order to leave comments, you need to log in
Why is the procedure not updated?
There is a procedure:
CREATE PROCEDURE [dbo].[AddHotel]
@adress nvarchar,
@rating int,
@name nvarchar,
@line int,
@distanceToBeach int,
@distanceToAirport INT,
@cityName nvarchar
AS
BEGIN
DECLARE @CityID int
set @CityID = (SELECT Cities.Id FROM dbo.Cities WHERE Cities.Name = @cityName)
INSERT INTO [dbo].[Hotels]
([Name],[Address],[Rating], [DistanceToBeach], [DistanceToAirport], [Line], [Discription])
VALUES
(@name, @adress, @rating, @distanceToBeach, @distanceToAirport, @line, 'some discr')
END
SELECT Cities.Id FROM dbo.Cities WHERE Cities.Name = N'Название города'
, that is, it will return the id as needed. set @CityID = (SELECT Cities.Id FROM dbo.Cities WHERE Cities.Name = N(@cityName))
An error occurred while the batch was being executed
Answer the question
In order to leave comments, you need to log in
You have not specified the dimension of the input parameters NVARCHAR
.
Pointed out - did not help.Check the input value.
DECLARE @cityNameTest nvarchar(100)
SET @cityNameTest = N'Название города'
SELECT 1 WHERE @cityName = @cityNameTest
N
before the parameter means not UNICODE, but a function, and what is indicated in the error. Cities.Name
, which affects the comparison of strings. COLLATE . SELECT @CityID = Id FROM Cities WHERE [Name] = @cityName
IF @CityID IS NULL BEGIN
INSERT Cities([Name]) VALUE (@cityName)
SET @CityID = IDENT_CURRENT('Cities')
END
INSERT [Hotels]
is no area code field.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question