Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. declare @tableName sysname;
  2. declare @sSQL nvarchar(max);
  3.  
  4. declare cTablas cursor for
  5. select name
  6. from sys.tables
  7. where name like 'TBS01%';
  8.  
  9. open cTablas;
  10.  
  11. fetch next from cTablas into @tableName;
  12.  
  13. while @@FETCH_STATUS = 0
  14. begin
  15. print 'Trasladando ' + @tableName;
  16. set @sSQL = 'select * into [copia].dbo.' + QUOTENAME(@tableName) + ' from ' + QUOTENAME(@tableName);
  17. exec sp_executesql @sSQL;
  18. fetch next from cTablas into @tableName;
  19. end;
  20.  
  21. close cTablas;
  22. deallocate cTablas;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement