Change ANSI Setting in Dynamic SQL (Double Exec)


  

   DECLARE @Definition  nvarchar(max);
SET @Definition = N' CREATE TRIGGER dbo.ExecOnUpdateTest ON dbo.Test FOR UPDATE AS RETURN;';
EXEC ('SET ANSI_NULLS ON EXEC(''' + @Definition  + ''')')
 

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/36f40ee9-09e7-4741-9e45-15e3b8824c1a/how-to-create-a-trigger-from-dynamic-sql-with-proper-ansi-settings?forum=transactsql

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s