Why we append N in the Query while selecting or deleting a table rows

Posted by dhirenkaunar-15094 under Sql Server on 4/19/2012 | Points: 10 | Views : 912 | Status : [Member] | Replies : 1
Hi,

In got the below query in the net , and this query is selecting the indexes where object_id = N'[dbo].[test]'

SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[test]' )


My Question is what is the significance of using N before my selecting object (Underlined).

Thanks in advance..

Thanks & Rgards,
Dhiren Kumar Kaunar



Responses

Posted by: Pandians on: 4/19/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi

OBJECT_ID system function have two parameters (Object_name, Object_Type)

Both the Parameters are NVARCHAR data type. So, when we use NVARCHAR data.

N'' is used to force the data convert into (National Charactors) NVARCHAR... But, Its not mandatory but, Its recommended.

Its not mandatory when using OBJECT_ID function!

In some situation, Its mandatory when handling Multi-Lingual data (except English data)!

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

dhirenkaunar-15094, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response