Wednesday, March 7, 2012

DDL in a Transaction?

Can someone point me to a doc on including DDL in a transaction? I have
never seen this and I need to understand it.
Thanks,
MichaelSnake wrote:
> Can someone point me to a doc on including DDL in a transaction? I
> have never seen this and I need to understand it.
> Thanks,
> Michael
begin tran
create table T12345Test (col1 int not null primary key)
insert into T12345Test Values (1)
insert into T12345Test Values (2)
select * from T12345Test
Rollback
Select * from T12345Test
David Gugick
Quest Software|||Here's a trivial example in which the newly create table is gone after the
rollback.
BEGIN TRAN
CREATE TABLE MyTable(Col1 int)
ROLLBACK
Hope this helps.
Dan Guzman
SQL Server MVP
"Snake" <Snake@.discussions.microsoft.com> wrote in message
news:B1FF6942-7C35-44EB-BD03-764DFA0440D0@.microsoft.com...
> Can someone point me to a doc on including DDL in a transaction? I have
> never seen this and I need to understand it.
> Thanks,
> Michael|||why would anyone have the need to create a table on the fly? That
would mean they have no valid data model and are screwed up beyond
belief.
We need more information to repair this disaster.|||There are lots of reasons to do this, just because you've not experienced
those does not make it wrong.
Some reasons...
Knowledge Management system where you dynamically build an object model, we
wrote a system (product), the meta 'model' was stored in a fixed database
design but user tables where created based on the model.
Datawarehousing, Archiving to name another two.
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"--CELKO--" <jcelko212@.earthlink.net> wrote in message
news:1132195794.207649.327090@.g49g2000cwa.googlegroups.com...
> why would anyone have the need to create a table on the fly? That
> would mean they have no valid data model and are screwed up beyond
> belief.
> We need more information to repair this disaster.
>|||I sometimes include DDL in a transaction as part of physical schema change
scripts as an alternative to backup/restore. Joe's probably never run into
this since he always gets his data model right the first time :-)
Hope this helps.
Dan Guzman
SQL Server MVP
"Tony Rogerson" <tonyrogerson@.sqlserverfaq.com> wrote in message
news:OrZLtO16FHA.1020@.TK2MSFTNGP15.phx.gbl...
> There are lots of reasons to do this, just because you've not experienced
> those does not make it wrong.
> Some reasons...
> Knowledge Management system where you dynamically build an object model,
> we wrote a system (product), the meta 'model' was stored in a fixed
> database design but user tables where created based on the model.
> Datawarehousing, Archiving to name another two.
> --
> Tony Rogerson
> SQL Server MVP
> http://sqlserverfaq.com - free video tutorials
>
> "--CELKO--" <jcelko212@.earthlink.net> wrote in message
> news:1132195794.207649.327090@.g49g2000cwa.googlegroups.com...
>

No comments:

Post a Comment