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 2000 Forums
 Transact-SQL (2000)
 use of N' character in queries

Author  Topic 

cognos79
Posting Yak Master

241 Posts

Posted - 2008-02-26 : 10:50:19
why do sometimes we have to use N' before the query. what does adding N' do. e.g.

exec sp_executesql N'
select cast('+@c2field+' as float) from contact2 where userdef12='+''''+cast(@contractnumber as varchar(6))+'''and isnumeric(' +@c2field+')=1',N'@existingamount float output',@existingamount output

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-02-26 : 10:51:20
N' denotes that you are providing unicode string literal.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

cognos79
Posting Yak Master

241 Posts

Posted - 2008-02-26 : 10:52:11
could you please elaborate more...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-26 : 11:07:25
Refer
http://databases.aspfaq.com/general/why-do-some-sql-strings-have-an-n-prefix.html

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-02-26 : 11:19:01
unicode saves chars in 2 bytes rather than in one and so enables you to save chinese, japanese, etc.. characthers.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

cognos79
Posting Yak Master

241 Posts

Posted - 2008-02-26 : 11:25:07
thanks guys...
Go to Top of Page
   

- Advertisement -