all groups > sql server clients > april 2006 >
You're in the

sql server clients

group:

Drop column in transaction


Drop column in transaction Daniel Mauric
4/25/2006 3:32:18 AM
sql server clients:
I perform a DROP COLUMN and it works fine. Yet if I do it while in
transaction the column doesn't get dropped and I get no exception. Any ideas
as to why that would happen ? I'm using ADO & MSSQL 2k

Regards,
Danny


Re: Drop column in transaction Hugo Kornelis
4/26/2006 12:15:07 AM
On Tue, 25 Apr 2006 03:32:18 +0200, "Daniel Mauric" <danny at neobee dot
[quoted text, click to view]

Hi Danny,

Are you sure that the transaction is being committed before you drop the
connection? If the connection is broken while a transaction is open, SQL
Server will automatically rollback a transaction.

Other than that, this should not happen. Run the below repro in QA to
see for yoursellf how a column *can* be dropped within a transaction,
but is directly restored (with no exception) if the transaction is
rolled back rather than committed.

CREATE TABLE test
(col1 int NOT NULL,
col2 int NOT NULL)
INSERT INTO test
VALUES (1, 2)
go
BEGIN TRANSACTION
ALTER TABLE test
DROP COLUMN col2
SELECT * FROM test
ROLLBACK TRANSACTION
SELECT * FROM test
go
BEGIN TRANSACTION
ALTER TABLE test
DROP COLUMN col2
SELECT * FROM test
COMMIT TRANSACTION
SELECT * FROM test
go
DROP TABLE test
go


--
AddThis Social Bookmark Button