September 7, 2010 at 10:57 pm
Hello,
I have an stored procedure for inserting values
create Procedure proc_Details_Insert
(
@Location nvarchar(4000),
)
as
Begin
INSERT INTO [Details] ([Location]) VALUES @Location)
End
It gives me error If I add prefix N for Unicode string
INSERT INTO [Details] ([Location]) VALUES N@Location)
How to resolve this? My column Location takes unicode values
Regards
Asif
September 7, 2010 at 11:01 pm
Try
INSERT INTO [Details] ([Location]) VALUES N''@Location
or
INSERT INTO [Details] ([Location]) VALUES N'@Location
one of the above should resolve ur problem
-Lk
September 7, 2010 at 11:41 pm
Nothing needs resolving. The parameter is defined as an nvarchar, hence it is an nvarchar and will be inserted into the table as an nvarchar. The N prefix is only needed for literal strings. Because you have a typed parameter, SQL knows what the data type is.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 7, 2010 at 11:44 pm
luckysql.kinda (9/7/2010)
TryINSERT INTO [Details] ([Location]) VALUES N''@Location
or
INSERT INTO [Details] ([Location]) VALUES N'@Location
Neither will work, as you would know if you'd done a syntax check before posting.
INSERT INTO [Details] ([Location]) VALUES N''@Location
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ''.
INSERT INTO [Details] ([Location]) VALUES N'@Location
Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark after the character string '@Location
'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '@Location
'.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply