Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Setting N before value in Stored Procedure for

Author  Topic 

velnias2010
Posting Yak Master

125 Posts

Posted - 2010-08-13 : 09:33:42
I have a stored procedure as follows

ALTER PROCEDURE [dbo].[spInsertContactUs]
(
@title VARCHAR(20) = default,
@forename VARCHAR(100) = default,
@surname VARCHAR(100) = default,
@gender VARCHAR(50) = default,
@address1 VARCHAR(100) = default,
@address2 VARCHAR(100) = default,
@city VARCHAR(50) = default,
@county VARCHAR(50) = default,
@country INT = default,
@zipcode VARCHAR(50) = default,
@email VARCHAR(200) = default,
@comments NVARCHAR(MAX) = default,
@mailinglist BIT = default,
@address3 VARCHAR(100) = default,
@dateOfBirth datetime = default
)
AS
SET NOCOUNT ON

INSERT INTO tblContactUs (
dateAdded,
title,
forename,
surname,
gender,
address1,
address2,
city,
county,
country,
zipcode,
email,
comments,
mailinglist,
address3,
dateOfBirth)
VALUES (
getdate(),
@title,
@forename,
@surname,
@gender,
@address1,
@address2,
@city,
@county,
@country,
@zipcode,
@email,
@comments,
@mailinglist,
@address3,
@dateOfBirth
)

SET NOCOUNT OFF
RETURN
;

Now where I insert Comments I want to put N in front of that to cater for entering russian characters

i.e as UPDATE texts SET title = N'" + TextBoxRU.Text + "

Cheers

Kristen
Test

22859 Posts

Posted - 2010-08-13 : 09:51:33
Use Nvarchar for @parameter instead of Varchar

or CONVERT(Nvarchar(999), TextBoxRU.Text)

but if TextBoxRU.Text is not already Nvarchar you will have lost the extended character information.
Go to Top of Page

velnias2010
Posting Yak Master

125 Posts

Posted - 2010-08-13 : 09:56:08
Hey Kristen that SQL statement was just an example, if the Stored Procedure above I have the issue with.

I.e I dont konw how to add N to the @comments line in my SP. You can see also I do declare comments as NVARCHAR
@comments NVARCHAR(MAX) = default,

Basically this works
N'SomeRussian'
N@comments

Doesnt, how can I get around this ?
Go to Top of Page

velnias2010
Posting Yak Master

125 Posts

Posted - 2010-08-13 : 10:45:56
I just tried the following

ALTER PROCEDURE [dbo].[spInsertContactUs]
(
@title VARCHAR(20) = default,
@forename VARCHAR(100) = default,
@surname VARCHAR(100) = default,
@gender VARCHAR(50) = default,
@address1 VARCHAR(100) = default,
@address2 VARCHAR(100) = default,
@city VARCHAR(50) = default,
@county VARCHAR(50) = default,
@country INT = default,
@zipcode VARCHAR(50) = default,
@email VARCHAR(200) = default,
@comments NVARCHAR(MAX) = default,
@mailinglist BIT = default,
@address3 VARCHAR(100) = default,
@dateOfBirth datetime = default
)
AS
SET NOCOUNT ON

INSERT INTO tblContactUs (
dateAdded,
title,
forename,
surname,
gender,
address1,
address2,
city,
county,
country,
zipcode,
email,
comments,
mailinglist,
address3,
dateOfBirth)
VALUES (
getdate(),
@title,
@forename,
@surname,
@gender,
@address1,
@address2,
@city,
@county,
@country,
@zipcode,
@email,
CONVERT(Nvarchar(999), @comments),
@mailinglist,
@address3,
@dateOfBirth
)

SET NOCOUNT OFF
RETURN
;



But no joy the value entered was '?????' but saved as '�дмин'
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-08-15 : 07:41:51
When you are calling your SP then how you are giving the parameters?
You should call the SP with N'?????' instead of '?????' for parameter @comments.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -