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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Using N prefix in stored proc parameter

Author  Topic 

NavNav
Starting Member

2 Posts

Posted - 2010-10-14 : 11:47:46
Hi

I need to use the N prefix to insert foreign characters but how do I add the N prefix to a sql paramter??
I know how to do this using a raw string but not with a parameter when using a stored proc.

So this is the SQL that is working correctly;
Declare @company_name as nvarchar(30)
SET @company_name = N'gelbo'
INSERT INTO companies (company_name) VALUES (@company_name)

But how do I this when I have a stored proc with a parameter @company_name. I want to do something like this;
CREATE PROCEDURE [dbo].[new_company_add](
@company_name nvarchar(30)
)
AS
BEGIN
INSERT INTO companies (company_name) VALUES (N@company_name)
END

Any ideas??? Thank you.

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-10-14 : 11:57:33
The N just tells the parser that the string literal should be or is a double-byte (unicode) string. Since your parameter is already of type NVARCHAR the parser knows that what it is. So, no need for the N in the case you have shown above.
Go to Top of Page

NavNav
Starting Member

2 Posts

Posted - 2010-10-14 : 13:46:33
Thanks Lamprey

That makes sense. It seems that my issue is that ColdFusion can't handle this when using a stored proc (although I'm looking into a possible solution through the CF Admin). A direct insert worked as expected.

Thanks for the reply.
Go to Top of Page
   

- Advertisement -