Question

I need to insert Tamil language into SQL Server 2005. I have tried using Insert or Update query, it worked fine. While going to stored procedure, I don't know how to pass the parameter.

ALTER PROCEDURE [dbo].[spr_Sam]
   @Row_Id       int            = NULL,
   @Description_Ta   nvarchar(MAX)  = null
AS
BEGIN
   update tblTest set  
   Description_Ta   = @Description_Ta
   where Row_Id = @Row_Id
END

exec [dbo].[spr_Sam] 2, 'பெண்டிரேம்';

If I execute this it gets inserted as ?????.

exec [dbo].[spr_Sam] 2, N'பெண்டிரேம்';

If I execute this it gets inserted correctly.. but I don't know how to pass that 'N' from my C# Application. I used a text-box to get that Description_Ta parameter.

Was it helpful?

Solution 2

Here is the correct update statement:

update tblTest
    set  Description_Ta  = @Description_Ta
where Row_Id = @Row_Id;

You don't need single quotes around a variable.

But, I think the posting is confused. To call the procedure use:

exec [dbo].[spr_Sam] 2, N'பெண்டிரேம்';

To modify it:

ALTER PROCEDURE [dbo].[spr_Sam]     
    @Row_Id      int            = NULL,
    @Description_Ta  nvarchar(MAX)  = null
AS
BEGIN
    update tblTest
        set Description_Ta  = @Description_Ta
        where Row_Id = @Row_Id;
END;

You shouldn't have arguments when you define the stored procedure.

OTHER TIPS

C# should add the N automatically if you use SqlDbType.NVarChar for SQLParameter

You must be using SqlDbType.VarChar of course

The MSDN doc for SqlDbType states (my bold)

VarChar: A variable-length stream of non-Unicode characters...

...

NVarChar: A variable-length stream of Unicode characters...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top