0

I have a SQL Server query from third party like:

SELECT * FROM SC.TOY T WHERE T.IS_SMALL != N'Y' AND T.NAME = 'TRUCK'

I am confused about usage of apostrophe after N and Y. Can someone please help me explaining what does it exactly means?

Nikhil Joshi
  • 817
  • 2
  • 12
  • 34
  • http://databases.aspfaq.com/general/why-do-some-sql-strings-have-an-n-prefix.html – christof13 Jun 25 '14 at 13:48
  • Amazing, this was quick. So N stands for National language character set and helps in converting CHAR to NCHAR, and TEXT as NTEXT and VARCHAR to NVARCHAR. Thanks for the help. – Nikhil Joshi Jun 25 '14 at 13:52
  • It doesn't convert. `N` specifies a NVARCHAR or NCHAR value. Quotes without a preceding N define a VARCHAR or CHAR value. – ypercubeᵀᴹ Jun 25 '14 at 13:54
  • Not sure why -1, I am new bie to SQL Server and trying to learn things and I did google like -- "SQL Server apostrophe in where" – Nikhil Joshi Jun 25 '14 at 13:54

2 Answers2

1

It means that the 'Y' is stored in a table either as either ntext, nchar, nvarchar

alwaysVBNET
  • 3,150
  • 8
  • 32
  • 65
0

SQL Server has char and varchar as types where each character is represented by one byte. Unicode types are nchar and nvarchar (as in native char or national language character set) where charactes are represented by two bytes per character. If one has to assign or give some literal text it is necessary to indicate which type of text it is. So

   'Hello' is a  char literal
  N'Hello' is a nchar literal
Mithrandir
  • 24,869
  • 6
  • 50
  • 66