Skip to main content
Question Protected by gnat
Tweeted twitter.com/#!/StackProgrammer/status/221281150759473154
Rewrote the question and the title.
Source Link
Arseni Mourzenko
  • 139.2k
  • 32
  • 359
  • 544

sql server 2008 insert statement question Why do we need to put N before strings in Microsoft SQL Server?

I amI'm learning sql server 2008 tT-sqlSQL.

To From the examples I've seen, to insert text in a varchar typevarchar() cell, I can write just needthe string to insert a string 'abc', but for nvarchar typenvarchar() cells, I need to addevery example prefix the strings with the letter N in front (N'abc').

I havetried the following query on a table employee, itwhich has 2 fieldsnvarchar() rows, firstname and lastname, they are both nvarchar(20).

insert into employee values('abc', 'def'); I test it, it works fine, seems likeso the prefix N is not required.:

insert into [TableName] values ('Hello', 'World')

Why we need to addthe strings are prefixed with N in front for nvarchar type, what'severy example I've seen?

What are the propros or con if we are notcons of using itthis prefix?

sql server 2008 insert statement question

I am learning sql server 2008 t-sql.

To insert a varchar type, I just need to insert a string 'abc', but for nvarchar type, I need to add N in front (N'abc').

I have a table employee, it has 2 fields, firstname and lastname, they are both nvarchar(20).

insert into employee values('abc', 'def'); I test it, it works, seems like N is not required.

Why we need to add N in front for nvarchar type, what's the pro or con if we are not using it?

Why do we need to put N before strings in Microsoft SQL Server?

I'm learning T-SQL. From the examples I've seen, to insert text in a varchar() cell, I can write just the string to insert, but for nvarchar() cells, every example prefix the strings with the letter N.

I tried the following query on a table which has nvarchar() rows, and it works fine, so the prefix N is not required:

insert into [TableName] values ('Hello', 'World')

Why the strings are prefixed with N in every example I've seen?

What are the pros or cons of using this prefix?

spelling and personal stuff cleanup
Source Link
gnat
  • 20.5k
  • 29
  • 117
  • 309

I am learning sql server 2008 t-sql.

toTo insert a varchar type, I just need to insert a string 'abc', but for nvarchar type, I need to add N in front (N'abc').

I have a table employee, it has 2 fields, firstname and lastname, they are both nvarchar(20).

insert into employee values('abc', 'def'); I test it, it works, seems like N is not required.

please explain to me whyWhy we need to add N in front for nvarchar type, whatswhat's the pro or con if we are not using it?

I am learning sql server 2008 t-sql.

to insert a varchar type, I just need to insert a string 'abc', but for nvarchar type, I need to add N in front (N'abc')

I have a table employee, it has 2 fields, firstname and lastname, they are both nvarchar(20).

insert into employee values('abc', 'def'); I test it, it works, seems like N is not required.

please explain to me why we need to add N in front for nvarchar type, whats the pro or con if we are not using it?

I am learning sql server 2008 t-sql.

To insert a varchar type, I just need to insert a string 'abc', but for nvarchar type, I need to add N in front (N'abc').

I have a table employee, it has 2 fields, firstname and lastname, they are both nvarchar(20).

insert into employee values('abc', 'def'); I test it, it works, seems like N is not required.

Why we need to add N in front for nvarchar type, what's the pro or con if we are not using it?

Source Link
qinking126
  • 551
  • 1
  • 5
  • 6

sql server 2008 insert statement question

I am learning sql server 2008 t-sql.

to insert a varchar type, I just need to insert a string 'abc', but for nvarchar type, I need to add N in front (N'abc')

I have a table employee, it has 2 fields, firstname and lastname, they are both nvarchar(20).

insert into employee values('abc', 'def'); I test it, it works, seems like N is not required.

please explain to me why we need to add N in front for nvarchar type, whats the pro or con if we are not using it?