سؤال

I'm using stored procedure to delete a row from MSSQL database based on a column that uses nvarchar(100) and Persian language. when i want to insert into this column, i use the word N before the record to be able to perform the insert operation :

insert into materialPrice values(  N'persian word',1000,100,0,0,0,0)

the problem is when i want to delete the same record, stored procedure does not work :

create proc spRemoveMaterial
@materialName nvarchar(100)
as
begin 
delete from materialPrice where materialName = @materialName
end 

I've tried to use N before @materialName but it returend syntax error. how could it be done ?

هل كانت مفيدة؟

المحلول 2

The problem was with the database collation, following code has fixed it :

ALTER database MaterialDB COLLATE Persian_100_CI_AS

نصائح أخرى

The N is a marker that causes the string literal to be represented in Unicode--implying that you are inserting into a Unicode column.

You should be able to convert the variable to Unicode with cast. Something like:

cast(@materialName as nvarchar(100))

With the correct type (nchar or nvarchar) and length to match the column.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top