What does N' stands for in a SQL script ? (the one used before characters in insert script)
N
is used to specify a unicode string.
Here's a good discussion: Why do some SQL strings have an 'N' prefix?
In your example N
prefix is not required because ASCII characters (with value less than 128) map directly to unicode. However, if you wanted to insert a name that was not ASCII then the N
prefix would be required.
INSERT [dbo].[TableName] ([Sno], [Name], [EmployeeId], [ProjectId], [Experience])
VALUES (1, N'Wāhi', 'ESD157', 'FD080', 7)
The "N"
prefix stands for National Language in the SQL-92 standard, and is used for representing unicode characters.
Any time you pass Unicode data to SQL Server you must prefix the Unicode string with N
.
It is used when the type is from NVARCHAR
, NCHAR
or NTEXT
.
For more info refer to this: Why do some SQL strings have an 'N' prefix?
'abcd'
is a literal for a [var]char
string (or maybe text
, but varchar(max)
would be more common now) - occupying 4 bytes memory, and using whatever code-page the SQL server is configured for. N'abcd'
is a literal for a n[var]char
string (or maybe ntext
, but nvarchar(max)
would be preferable), occupying 8 bytes of memory using UTF-16. This allows for full international usage, and frankly n[var]char
should probably be the default in most systems.