July 30, 2008 at 11:39 am
I have a silly question I was wondering if someone can help me understand. I have the following SQL Statement that I saw :
IF EXISTS(SELECT * FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Orders]') AND type in (N'U'))
PRINT 'Exists!'
ELSE
PRINT 'Don''t Exists'
When I run this code it works. Can someone tell me what is the N for within the line N'[dbo].[Orders]. If I take out the N in both places the code still runs successfully. So, what is the purpose? or is there a purpose?
July 30, 2008 at 12:27 pm
N is used before character data literals to specify that it is a unicode string (nvarchar, nchar data types). SQL Server will normally do an implicit conversion of non-unicode strings to unicode, but there is a slight performance hit when this occurs.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
July 30, 2008 at 2:19 pm
Thanks for the explanation.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply