?
Solved

What does the N' mean in the code "object_id(N'[Northwind].[dbo].[Categories2]') "?

Posted on 2005-04-02
5
Medium Priority
?
1,717 Views
Last Modified: 2008-03-06
I got the code below from this site:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/howtosql/ht_dts_tools_6g6d.asp.

Can someone tell me what does the N' mean and what relationship does it has with "[Northwind].[dbo].[Categories2] code  next to it in the WHERE statement (second line) of the code below?

IF EXISTS (SELECT * from sysobjects
   WHERE id = object_id(N'[Northwind].[dbo].[Categories2]') AND
   OBJECTPROPERTY(id, N'IsUserTable') = 1)
   DROP Table [Northwind].[dbo].[Categories2]
GO


THe FireBird thanks you.

0
Comment
Question by:BirdsOfFire1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 13690095
N' means Unicode characters coding.
To proper function In case when names have characters outside ASCII
0
 
LVL 17

Accepted Solution

by:
mokule earned 500 total points
ID: 13690113
from BOL

Unicode strings

Unicode strings have a format similar to character strings but are preceded by an N identifier (N stands for National Language in the SQL-92 standard). The N prefix must be uppercase. For example, 'Michél' is a character constant while N'Michél' is a Unicode constant. Unicode constants are interpreted as Unicode data, and are not evaluated using a code page. Unicode constants do have a collation, which primarily controls comparisons and case sensitivity. Unicode constants are assigned the default collation of the current database, unless the COLLATE clause is used to specify a collation. Unicode data is stored using two bytes per character, as opposed to one byte per character for character data
0
 

Author Comment

by:BirdsOfFire1
ID: 13690254
To: mokule

I have MS Server SQL 8.0, which I assume is not the SQL-92 standard.   Will just "object_id([Northwind].[dbo].[Categories2]) work?  I took out the N' in the statement above.

When should I use the N' in the object_id?  


The Firebird
Thanks

0
 
LVL 17

Expert Comment

by:mokule
ID: 13691143
You must use it when there are characters in the string having code outside ASCII
0
 
LVL 2

Assisted Solution

by:ChillAmmar
ChillAmmar earned 500 total points
ID: 13697374
Hi,

N'  is used when we require to convert a particular string to a NVARCHAR format....
you can do without N if your function does not require that you explicitly pass a Nvarchar.

For some system procedures or function is is required that you pass a Nvarchar and not a VArchar
eg.

Execute sp_executesql N'select * from dtproperties'
this statement would work fine but
Execute sp_executesql 'select * from dtproperties'
this statement would give you an error

Hope this helps

Regards,
Ammar
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question