I have a scenario to alter the columns of few user defined table types programmatically. To do this, I need to drop the referenced stored procedures. So, I have designed my SQL scripts to do following activities:

1. Taking the backup of stored procedures from sys.sql\_modules table into a staging table (definition, uses\_ansi\_nulls and uses\_quoted\_identifier columns).
2. Dropping the stored procedure.
3. Altering the user defined table types.
4. Now, using the staging table's definition column to recreate the stored procedure, but I am not able to use the values of uses\_ansi\_nulls and uses\_quoted\_identifier columns. **How can I reuse the uses\_ansi\_nulls and uses\_quoted\_identifier column while recreating the stored procedure.**

I am using cursor to get the content of staging columns into variables and then using exec() executing the definition of stored procedure like below:

```
 SET @ProcDefinition_Complete=@uses_ansi_nulls_Definition + CHAR(10)+' GO '+ CHAR(10)+@uses_quoted_identifier_Definition+ CHAR(10)+' GO '+  CHAR(10)+ @ProcDefinition

        EXEC (@ReferencingDefinition_Complete)

```

Above statement gives error:

```
 Incorrect syntax near 'GO'. 

```

And when I remove GO statement then it gives the error:

```
'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.

```