-2

What is N in =N'...' mentioned in the example here.

USE msdb ;
GO

EXEC dbo.sp_add_job
@job_name = N'Ad hoc Sales Data Backup', 
@enabled = 1,
@description = N'Ad hoc backup of sales data',
@owner_login_name = N'françoisa',
@notify_level_eventlog = 2,
@notify_level_email = 2,
@notify_level_netsend = 2,
@notify_level_page = 2,
@notify_email_operator_name = N'François Ajenstat',
@notify_netsend_operator_name = N'François Ajenstat', 
@notify_page_operator_name = N'François Ajenstat',
@delete_level = 1 ;
GO
Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
xyz
  • 2,160
  • 3
  • 20
  • 31
  • @wewesthemenace also thought the same..so this is to tell msdb proc which kind of data we are going to enter? – xyz Mar 24 '15 at 08:26
  • Yes, you could also remove the `N` but that will put an additional cost for conversion. also @Patrick Hofman's answer. – Felix Pamittan Mar 24 '15 at 08:27
  • @wewesthemenace and it is going to construct the tables accordingly? – xyz Mar 24 '15 at 08:27
  • What do you mean? Are you talking about the `sp_add_job`? – Felix Pamittan Mar 24 '15 at 08:28
  • @wewesthemenace sorry wrong context..let say for `sysmail_allitems`..and if we use N in the proc while exec `msdb.dbo.sp_send_dbmail` and passing param with `N` – xyz Mar 24 '15 at 08:31

4 Answers4

2

The database can't see the difference between a varchar literal and a nvarchar literal. When you put in a string ('abc'), it doesn't know you actually meant this to be unicode. (This is very important sometimes to get the right encoding, for example when using Arabic or Greek characters.)

The N string literal prefix will indicate that string is a unicode literal.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
1

When dealing with Unicode string constants in SQL Server you must precede all Unicode strings with a capital letter N, as documented in the SQL Server Books Online topic "Using Unicode Data". The "N" prefix stands for National Language in the SQL-92 standard, and must be uppercase. If you do not prefix a Unicode string constant with N, SQL Server will convert it to the non-Unicode code page of the current database before it uses the string.

It's declaring the string as nvarchar data type, rather than varchar.

check out this.The following articles have some good information on the question

http://databases.aspfaq.com/general/why-do-some-sql-strings-have-an-n-prefix.html http://support.microsoft.com/default.aspx/kb/239530

Ajay
  • 6,418
  • 18
  • 79
  • 130
0

That N'..' means the parameter is nvarchar data type

Raj
  • 10,653
  • 2
  • 45
  • 52
0

It's declaring the string as nvarchar data type, rather than varchar Here Is Best Answer

Community
  • 1
  • 1
A_Sk
  • 4,532
  • 3
  • 27
  • 51