Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why are alter-table script transcations like this

Status
Not open for further replies.

dragonwell

Programmer
Oct 21, 2002
863
US
When I look at the script generated for making a change to a table there are some thing I don't understand about transactions. Why are there multiple BEGIN TRANSCATION and COMMIT statements? for instance
Code:
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.RouteRun
	DROP CONSTRAINT FK_RouteRun_Driver
GO
COMMIT
...etc

To me it seems like the entire script should have it's own single transaction. Even if the part of the sample above completes but then something later in the script errors, that DROP CONSTRAINT will still be committed. Right?
 
yes but if you don;t do it that way then the drop hasn't happened and it will error out in trying to make the change.

Questions about posting. See faq183-874
Click here to help with Hurricane Relief
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top