Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- declare @tableName sysname;
- declare @sSQL nvarchar(max);
- declare cTablas cursor for
- select name
- from sys.tables
- where name like 'TBS01%';
- open cTablas;
- fetch next from cTablas into @tableName;
- while @@FETCH_STATUS = 0
- begin
- print 'Trasladando ' + @tableName;
- set @sSQL = 'select * into [copia].dbo.' + QUOTENAME(@tableName) + ' from ' + QUOTENAME(@tableName);
- exec sp_executesql @sSQL;
- fetch next from cTablas into @tableName;
- end;
- close cTablas;
- deallocate cTablas;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement