March 19, 2011 at 12:53 am
why do we use quoted identifier
March 21, 2011 at 9:28 am
Suppose you had created a column with the name "desc" as in
Create Table Customer
( CustomerID int
, CustomerName varchar(100)
, Desc varchar(max)
)
If you wanted to select the data
SELECT
CustomerID
, CustomerName
, Desc
from Customer
order by CustomerName Desc
You have an error. Instead you need a quoted identifier or brackets. You can do this:
SELECT
CustomerID
, CustomerName
, [Desc]
from Customer
order by CustomerName Desc
or with quoted identifier on, you can do this:
SELECT
CustomerID
, CustomerName
, "Desc"
from Customer
order by CustomerName Desc
SET QUOTED_IDENTIFIER - http://msdn.microsoft.com/en-us/library/aa259228%28v=sql.80%29.aspx
March 21, 2011 at 2:56 pm
Or don't follow microsofts poor example of using reserved words for column names!
Best practices? I think not. 😀
March 21, 2011 at 3:57 pm
The problem comes in when T-SQL grows and what was an acceptable word in the previous version is not in this one.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply