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 |
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2011-02-05 : 18:51:45
|
So go statements will run back of code.My concerns, thoughts.What i'm afraid of is if some GO statement backfire then the others will execute and binding this with a use of transactions you may have a problem.I think, go's must be handled with caution and no task interacts with the next one.Unless transactions can surround all the go's(I'm not aware of that.) or use triggers but it gets complex.Am i wrong, right, in the middle?Thanks. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2011-02-05 : 19:05:49
|
I am not sure what you are referring to. I too would need an example, since you asked me to take a look here.... Poor planning on your part does not constitute an emergency on my part. |
 |
|
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2011-02-05 : 21:24:56
|
Ok i guess it's my mistake.I'm accustomed to see GO on the begging of sp's likeUSE [test4]GO/****** Object: StoredProcedure [dbo].[sp_selectan] Script Date: 02/05/2011 16:19:56 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO So i assumed it can go deeper in the sp to separate p.e. one insert from the next one.I guess i was wrong. |
 |
|
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2011-02-05 : 21:25:57
|
Sorry again can you post a function example with go?What would be the usability in there?Thanks. |
 |
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2011-02-05 : 21:42:12
|
That isn't a procedure. GO is a batch separatorThe property sets above the procedure are not directly part of the procedure itself. The functionality of the GO statement is to separate a batch of commands.Try this to see "why" the functionality , as you put it, is required:USE masterCreate View [test]as Select Top 1 from sysobjectsSelect * FROM testDrop view test After you see what happens, stick a "GO" statement between those four commands and you will see the use demonstrated.You would NOT see the GO statement inside an actual stored procedure, because it is effectively a hard stop, and commit for the statements above it in a T-SQL batch. Poor planning on your part does not constitute an emergency on my part. |
 |
|
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2011-02-05 : 22:09:32
|
Thanks. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|