﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / Applying TRANSACTION for DDL statements / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 04:41:43 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Applying TRANSACTION for DDL statements</title><link>http://www.sqlservercentral.com/Forums/Topic1071141-392-1.aspx</link><description>Hey thanks HowardW.I got the details and now I have updated myself :-PRegards,AJ</description><pubDate>Tue, 01 Mar 2011 07:22:55 GMT</pubDate><dc:creator>AJ07</dc:creator></item><item><title>RE: Applying TRANSACTION for DDL statements</title><link>http://www.sqlservercentral.com/Forums/Topic1071141-392-1.aspx</link><description>No, pretty much everything that happens within the scope of an individual database is part of the transaction and can be rolled back, including DDL and indeed TRUNCATE (another transaction myth).Have a look here for T-SQL Statements that are not allowed within a transaction:[url]http://msdn.microsoft.com/en-us/library/ms191544.aspx[/url]</description><pubDate>Tue, 01 Mar 2011 06:12:59 GMT</pubDate><dc:creator>HowardW</dc:creator></item><item><title>Applying TRANSACTION for DDL statements</title><link>http://www.sqlservercentral.com/Forums/Topic1071141-392-1.aspx</link><description>Hi Guys,          I had this understanding that the DDL statements are autocommit statements and if any DDL statement is written in any TRANSACTION then as the DDl statement executes all the DML before it got commit.I tried below script -CREATE TABLE AJ1 (ID INT IDENTITY(-1,1))--CREATE TABLE AJ2(ID INT IDENTITY(-1,-1))INSERT INTO AJ1 Default valuesINSERT INTO AJ1 Default valuesINSERT INTO AJ1 Default valuesBEGIN TRANINSERT INTO AJ1 Default valuesINSERT INTO AJ1 Default valuesINSERT INTO AJ1 Default values--DROP TABLE AJ1CREATE TABLE AJ2(ID INT IDENTITY(-1,-1))INSERT INTO AJ1 Default valuesINSERT INTO AJ1 Default valuesINSERT INTO AJ1 Default valuesRollBack select * from AJ1select * from AJ2I am getting the below mentioned message - (1 row(s) affected)(1 row(s) affected)(1 row(s) affected)(1 row(s) affected)(1 row(s) affected)(1 row(s) affected)(1 row(s) affected)(1 row(s) affected)(1 row(s) affected)ID------------101(3 row(s) affected)Msg 208, Level 16, State 1, Line 23Invalid object name 'Aj2'So now I am a bit confused that DDL statements can be rolledback if written in TRANSACTION.Any suggestion or reference.Regards,AJ</description><pubDate>Tue, 01 Mar 2011 05:57:48 GMT</pubDate><dc:creator>AJ07</dc:creator></item></channel></rss>