SHARE
TWEET

Untitled

a guest Jun 15th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Create and populate new_TableImported
  2.  
  3. if object_id('old_TableImported') is not null drop table old_TableImported
  4. set transaction isolation level serializable;
  5. set xact_abort on;
  6. begin try
  7.     begin tran
  8.         if object_id('TableImported') is not null exec sp_rename 'TableImported', 'old_TableImported'
  9.         exec sp_rename 'new_TableImported', 'TableImported'
  10.     commit
  11. end try
  12. begin catch
  13.     if (xact_state() <> 0) rollback tran;
  14.     throw;
  15. end catch
  16. set transaction isolation level read committed;
  17. drop table old_TableImported
  18.      
  19. CREATE VIEW [export].[vSomeDataNeededOutside]
  20. AS
  21. select
  22.     t.*,
  23.     e.SomeField
  24. from dbo.OneOfMyTables t
  25.     left join (
  26.         select ...
  27.         from TableImported
  28.         group by ...
  29.     ) e on ...
  30. where ...
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top