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)
 Create stored procedure - using begin & end and GO command

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-20 : 09:20:00
herbert chin writes "HI,


BEGIN...END
There are considerable amount of confusion with this subject. I understand that the begin...end statement should be a way to make the commit of the transaction much more streamline and not to allow the program to be confused with executing the next set of stored procedure.

Is this the only reason why this is strongly recommended?



GO
This is obviously clear.

However, does this have similar implication as with the BEGIN...END statement as above please?

I would appreciate your help. By the way, I am working as a DBA (not completely qualified) in a property software house and my prime task is to put the upgrade scripts together, compile them and ensure the upgrade runs succesfully. Thanks!"

Nazim
A custom title

1408 Posts

Posted - 2001-12-20 : 09:46:27
this is what BOL states about Begin and End

The BEGIN and END statements are used to group multiple Transact-SQL statements into a logical block. Use the BEGIN and END statements anywhere a control-of-flow statement must execute a block of two or more Transact-SQL statements.


Go is a signal for Executing a Query or a command in ISQL or OSQL. but it isnt a T-sql command


I would strongly suggest you to go thru Books Online . you will find loads of information in simple form.

Dont worry about you not being properly qualified or something like that. keep following Sqlteam and spend good amount of time reading sql stuff as i told u esp BOL and am sure in no time you will a good one. if any problem comes up you can always post it here , someone or another will definetly help you out.


HTH

-------------------------
"Success is when Preparedness meets Opportunity"
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2001-12-20 : 14:46:58
begin / end just create a block of statements
they are usually used to create flow control blocks

if condition
begin
....
end

the transaction processing statements you are talking about are

begin tran
commit tran
rollback tran
which are used for transaction control and don't create a statement block.

The go ends a batch
drop table #a
go
create table #a (i it)
select * from #a

If you run this it will get an error on the drop but still execute the new batch after the go. If the go was missing it would not execute.

Be careful about go statements becaues the are actioned even within a comment block if they come after a carriage return.



==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -