CRUD Statements  «Prev 

SQL Server Quotations and Datatypes

Using Literal Values

The following table indicates whether quotes are needed for each of the SQL Server datatypes:
DatatypeQuotes needed for literal values
BinaryNo
BitNo
Char(n)Yes
DatetimeYes
Decimal(p[,s])No
Float(n)No
ImageNo
IntNo
MoneyNo
NcharYes
NtextYes
NumericNo
NvarcharYes
RealNo
SmalldatetimeYes
SmallintNo
SmallmoneyNo
TextYes
TimestampNo
TinyintNo
UniqueidentifierYes if string, No if hexadecimal
VarbinaryNo
Varchar(n)No

Single versus double quotations

Microsoft recommends using single quotation marks for literal values, but you should know that you can, if desired, use double quotes by issuing the following Transact-SQL statement first:

SET QUOTED_IDENTIFIER OFF

Once you issue this Transact-SQL statement, you can use double quotes for the entire lifetime of your database connection. You do not have to issue this Transact-SQL statement before every statement that uses double quotes.