Click here to Skip to main content
14,788,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all, I want to save Korean Language in my MS Sql server table. but when i execute my procedure it save value like '???????' this. here is my sample code:-

alter PROCEDURE [dbo].[testsp]
	(	
		@Name	nvarchar(4000)
    )
AS

BEGIN

	SET NOCOUNT ON;

   INSERT INTO  dbo.tbl_test(testcolumn)

  VALUES (  @Name)

end



exicution code:-
exec [dbo].[testsp] @Name='?????'


and it save '????' question marks in my table column. can any one suggest me the solution.

What I have tried:

i search on google and got only one solution that use 'N' in your insert query. This solution working fine if i am using this like:-

alter PROCEDURE [dbo].[testsp]
	(	
		@Name	nvarchar(4000)
    )
AS

BEGIN

	SET NOCOUNT ON;

	set @Name=N'?????'

   INSERT INTO  dbo.tbl_test(testcolumn)

  VALUES (  @Name)

end


But i want to insert this value from my parameter which i passed in procedure.
Posted
Updated 8-Mar-21 20:45pm

1 solution

The "N" string prefix indicates that the string contains Unicode data:
'ABCDE'    Is ASCII data
N'ABCDE'   Is Unicode data
Similarly, the "N" in NVARCHAR indicates it is Unicode, without it the VARCHAR column is ASCII.
Your SP knows about and expects Unicode data, so it saves Unicode - but when you execute the procedure you have to hand it a Unicode string not an ASCII string.

So if your executing code passes a fixed Korean language string:
MS SQL ?? ???? ???? ???? ????.
Then it needs to be created with the Unicode prefix:
CALL MyStoredProcedure(N'MS SQL ?? ???? ???? ???? ????.')
Because if you don't, then it will pass an ASCII string and you will see "????" in your DB as a result:
CALL MyStoredProcedure('MS SQL ?? ???? ???? ???? ????.')


When you pass data to SQL from a presentation language such as C#, it will default to Unicode but other languages may use ASCII by default (for example, C)
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900
欧美图亚洲色另类偷偷自拍_欧美亚洲成人_欧美在线