Re: Drop column in transaction
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 26 Apr 2006 00:15:07 +0200
On Tue, 25 Apr 2006 03:32:18 +0200, "Daniel Mauric" <danny at neobee dot
net> wrote:
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
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
--
Hugo Kornelis, SQL Server MVP
.
- References:
- Drop column in transaction
- From: Daniel Mauric
- Drop column in transaction
- Prev by Date: Unable to Debug
- Next by Date: Re: query analyzer mru
- Previous by thread: Drop column in transaction
- Next by thread: Re: Query from One Server to Another
- Index(es):
Relevant Pages
|
Loading