Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SET QUOTED_IDENTIFIER OFF and usage of double quto

Author  Topic 

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2013-01-25 : 10:50:23
A developer had a stored procedure with this inside:
Print " >>>>> " + @Sql + @Where


I could not compile it, I originally thought it was an error in the code. Then I discovered with SET QUOTED_IDENTIFIER OFF, it would compile.

Does anyone have any thought if this is good coding style, i.e. using the double quotation marks? It seems unusual to me. What is the recommended setting on the Database for "Quoted Identifiers Enabled"?

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-01-25 : 11:23:42
By default, it is set to ON, so I leave it at that and use single quotes for strings. Also, some features indexed views, indexes on XML columns etc. require that you set QUOTED_IDENTIFIER ON before you create them. So unless there is a strong reason to do so, leave it ON.
SET QUOTED_IDENTIFIER ON
Print ' >>>>> ' + @Sql + @Where
Go to Top of Page

cstokes91
Yak Posting Veteran

72 Posts

Posted - 2013-01-25 : 11:27:09
This is one of those things to where that is going to be your call.

Ultimately, I would recommend that you leave it ON and stick with using single quotes since that is the most widely used practice but that is why they give you the option to switch it... The ability to customize things to your liking.
Go to Top of Page
   

- Advertisement -