Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Go command in Stored Proc causes proc to execute commands during compile

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-11-06 : 20:43:02
Jerry writes "This happened to me yesterday and I was a bit surprised. I wanted to put together a create table stored proc that:

1) Deleted an index
2) Deleted the table is exists
3) Recreate the table
3) Bind columns to defaults

Each of these units of work was separated by a "GO" statement. What happened when I save the proc was the proc was saved with the first statement (#1) and the rest of the following statements were executed and not saved with the proc. This caused me to actually delete the table and recreate it just by working within the development UI of the stored proc. I used a product from Lumigent, called Log Explorer, to help me track down why the contents of my table had been deleted and of course they were deleted because I doppped the whole table...arggg!!!.

I tested this be doing other stored procs by putting in multiple statements separated by "GO" and each time the first statement is saved in the proc and the rest of the statements are executed.

I can find nothing on Microsofts site that mentions this issue. Do you know of anywhere that mentions why this happens. I have made my staff aware of this anomaly and plan to avoid the "GO" statement in stored procs in the future. The "GO" does work fine in the query analyzer though.

Any info would be appreciated."
   

- Advertisement -