Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 8th, 2005, 06:46 AM
Authorized User
 
Join Date: Oct 2004
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Syntax Query

The code below is taken from the sp_executesql page in sql books online.

On the last but one line there is an 'N' before the literal.

Anyone know what it means?

/* Show not having access to variables from the calling batch. */
DECLARE @CharVariable CHAR(3)
SET @CharVariable = 'abc'
/* sp_executesql fails because @CharVariable has gone out of scope. */
sp_executesql N'PRINT @CharVariable'
GO
 
Old September 8th, 2005, 08:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

The 'N' is a qualifier signifying a UNICODE string. Thus, the expression:
Code:
N'PRINT @CharVariable'
indicates that the string enclosed in quotes should be encoded as a UNICODE string, rather than the default encoding on the server it is running on. This guarantees that the string and the '@' especially, will be correctly interpreted even if the code is run on a server configured in Sanskrit, for example.

Not necessary if you're running the Latin character sets, but documentation writers can't guarantee that...

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old September 8th, 2005, 08:37 AM
Authorized User
 
Join Date: Oct 2004
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks that makes it clear.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Query Syntax [email protected] SQL Language 1 May 1st, 2007 06:42 AM
Query syntax problem mateenmohd Access 2 October 12th, 2004 11:33 PM
MySQL syntax in query Tachyon Beginning PHP 1 June 26th, 2004 08:42 PM
Syntax error in query. Incomplete query clause. dispickle ADO.NET 3 April 16th, 2004 01:04 PM
QUERY SYNTAX singh_ginni Oracle 1 September 10th, 2003 07:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.