SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SET QUOTED_IDENTIFIER OFF and usage of double quto
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

denis_the_thief
Aged Yak Warrior

Canada
594 Posts

Posted - 01/25/2013 :  10:50:23  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3744 Posts

Posted - 01/25/2013 :  11:23:42  Show Profile  Reply with Quote
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

USA
60 Posts

Posted - 01/25/2013 :  11:27:09  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000