title: Is it possible to run multiple DDL statements inside a transaction (within SQL Server)?
body: <p>I'm wondering if it is possible to run multiple DDL statements inside a transaction. I'm specially interested on SQL Server, even though answers with other databases (Oracle, PostgreSQL at least) could also be interesting.</p>
  
  <p>I've been doing some "CREATE TABLE" and "CREATE VIEW" for the created table inside a transaction and there seems to be some inconsistencies and I'm wondering if the DDLs shouldn't be done inside the transaction...</p>
  
  <p>I could probably move the DDL outside the transaction but 
  I'd like to get some reference for this. What I have found this far:</p>
  
  <ul>
  <li>MSDN page <a href="http://msdn.microsoft.com/en-us/library/ms189122.aspx" rel="nofollow noreferrer">Isolation Levels in the Database Engine</a> tells clearly that <em>there are restrictions on what DDL operations can be performed in an explicit transaction that is running under snapshot isolation</em> - but I'm not using snapshot isolation and this should result as an error.
  
  <ul>
  <li>This could be interpreted so that DDL operations can be performend in an explicit transaction under different isolation levels?</li>
  </ul></li>
  <li><a href="http://download.oracle.com/docs/cd/B28359_01/gateways.111/b31049/ch3.htm#i1008272" rel="nofollow noreferrer">Oracle® Database Gateway for SQL Server User's Guide#DDL Statements</a> states that <em>only one DDL statement can be executed in a given transaction</em> - is this valid also for SQL Server used straight?</li>
  </ul>
  
  <p>For Oracle:</p>
  
  <ul>
  <li>Within SO question <a href="https://stackoverflow.com/questions/892923/unit-testing-ddl-statements-that-need-to-be-in-a-transaction">Unit testing DDL statements that need to be in a transaction</a> it is said that Oracle does implicit commit for a DDL statement? (even though no references)</li>
  </ul>
  
  <p>If it matters something, I'm doing this with Java through the JTDS JDBC driver.</p>
  
  <p>b.r. Touko</p>