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.
| Author |
Topic |
|
eevans
Starting Member
48 Posts |
Posted - 2009-03-23 : 10:10:25
|
| Hello,I have some code that looks like this...(Insert Into Statement)Go(Insert Into Statement 2)Go(Insert Into Statement 3)When I click 'Execute', the statements execute in consecutive order and everything's perfect.I would like to convert this into a single stored procedure. How could I go about doing this?Thanks! |
|
|
eevans
Starting Member
48 Posts |
Posted - 2009-03-23 : 10:51:44
|
| Would it be possible to substitute BEGIN/END for GO? |
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2009-03-23 : 11:28:48
|
| even inside the SP the statements will be executed consecutively, however you can have them in a single transaction which can be roll back all statements together. |
 |
|
|
darkdusky
Aged Yak Warrior
591 Posts |
Posted - 2009-03-23 : 12:39:46
|
| Are the 3 inserts going into different tables? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-23 : 12:46:27
|
| use of GO will ensure the end of one batch and start of other so if you use any variables which are declared on top it will be out of scope after first GO |
 |
|
|
eevans
Starting Member
48 Posts |
Posted - 2009-03-23 : 13:35:20
|
| Thanks all. Dardusky, the inserts are going into 3 different tables.I changed GO's to BEGIN/END's and it seems to work fine. |
 |
|
|
eevans
Starting Member
48 Posts |
Posted - 2009-03-23 : 13:37:24
|
| Also, I am not using Declare for any variables. |
 |
|
|
|
|
|