I\'ve got a Stored proc [A] that creates another stored proc [B]
[A] Will never be run by end users and has no parameters or other untrusted data. Instead it is used by
You need QUOTED_IDENTIFIER to be ON
where stored procedure A
is created. Note:
When a stored procedure is created, the SET QUOTED_IDENTIFIER and SET ANSI_NULLS settings are captured and used for subsequent invocations of that stored procedure.
Which, by implication, means that any stored procedure that creates stored procedures will pass on the settings that were in force during its own creation. E.g.:
set quoted_identifier on
go
create procedure ABC
as
exec('create procedure DEF as')
go
set quoted_identifier off
go
exec ABC
go
select definition,uses_quoted_identifier from sys.sql_modules
where object_id=OBJECT_ID('DEF')
produces:
definition uses_quoted_identifier
-------------------------------------- ----------------------
create procedure DEF as 1