what is quoted identifier

  • why do we use quoted identifier

  • 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

  • Or don't follow microsofts poor example of using reserved words for column names!

    Best practices? I think not. 😀

  • 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