Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 1st, 2012  |  syntax: None  |  size: 0.43 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Why is CREATE TABLE command not working in a user-defined transaction?
  2. BEGIN TRANSACTION T1
  3. CREATE TABLE temp
  4. (
  5. chisla char(1)
  6. )
  7.  
  8. SELECT count(chisla) AS Count, chisla AS My_Numbers
  9. FROM temp
  10. --GROUP BY chisla
  11. ORDER BY chisla
  12.  
  13. drop table temp
  14. COMMIT TRANSACTION T1
  15. GO
  16.        
  17. BEGIN TRY
  18.    BEGIN TRANSACTION
  19.    ...your code...
  20.    COMMIT TRANSACTION
  21. END TRY
  22. BEGIN CATCH
  23.    ...error reporting code here...
  24.    ROLLBACK TRANSACTION
  25. END CATCH;