Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

QUOTED_IDENTIFIER is a parse time setting but what if there are two in the batch?

$
0
0

BOL for this setting (2005-2012) hasn't changed.  It says it is a parse time setting which happens before any lines are executed.

SET QUOTED_IDENTIFIER OFF; DBCC useroptions EXEC(" IF EXISTS (SELECT * FROM sys.procedures WHERE name = 'insert_into_asdf')

DROP PROCEDURE dbo.insert_into_asdf ;"); EXEC(" CREATE PROCEDURE dbo.insert_into_asdf @name varchar(10) , @deleted bit AS BEGIN DBCC useroptions; --INSERT INTO dbo.asdf (name, deleted) VALUES (@name, @deleted); END;"); SET QUOTED_IDENTIFIER ON; SELECT OBJECTPROPERTY(object_id,'ExecIsQuotedIdentOn'), * FROM sys.objects WHERE type IN ('P','TR','V','IF','FN','TF') AND name = 'insert_into_asdf'

Something else is going on during execution that BOL is either leaving out or assuming i know.  The above shows that the proc is created with QI setting on.  If you comment the final QI ON statement it will be created with it off.  If the setting is set at parse time there must be something else going on that allows the string execution.

SET QUOTED_IDENTIFIER ON;
EXEC("
DROP PROCEDURE dbo.insert_into_asdf ;");
EXEC("
CREATE PROCEDURE dbo.insert_into_asdf @name varchar(10) , @deleted bit
AS
BEGIN
	DBCC useroptions;
	--INSERT INTO dbo.asdf (name, deleted) VALUES (@name, @deleted);
END;");
SET QUOTED_IDENTIFIER OFF;

If you flip the settings around the SQL doesn't execute with an incorrect syntax error.

thoughts?


-- dan http://dnhlmssql.blogspot.com/


Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>