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

Posted on 2005-04-02
Medium Priority
Last Modified: 2008-03-06
I got the code below from this site:

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]

THe FireBird thanks you.

Question by:BirdsOfFire1
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
LVL 17

Expert Comment

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

Accepted Solution

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

Author Comment

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

LVL 17

Expert Comment

ID: 13691143
You must use it when there are characters in the string having code outside ASCII

Assisted Solution

ChillAmmar earned 500 total points
ID: 13697374

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

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


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