
Have a nice copies of the companies! Posted: January 22, 2014. + ' select ' from ']' IF = + ' SET IDENTITY_INSERT ' OFF'Įxec sp_executesql NEXT FROM table_cursorįont-family: consolas, “Courier New”, courier, monospace Set = '' IF = + 'SET IDENTITY_INSERT ' ON ' set = + 'delete from ' ' set = + 'insert into ' ('+ + ')' set = 'SELECT COUNT(*) as C FROM '.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME =' '' ' AND COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, ' 'IsIdentity' ') = 1' DELETE from into exec sp_executesql SUM(C) FROM 0, 1) WITH NOWAIT Select ']' - select COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME AND COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1 INTO SELECT ']' FETCH NEXT from column_cursor Set = 'SELECT COLUMN_NAME FROM '.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ' '' ' and COLUMN_NAME ' 'timestamp' '' DELETE from into exec sp_executesql column_cursor CURSOR for select COLUMN_NAME from '' OPEN column_cursor Insert into exec sp_executesql table_cursor CURSOR for select name from table_cursor Insert statements for procedure here declare varchar(1000)ĭeclare int declare nvarchar ( max) = 'select name from '.sys.all_objects where type=' 'U' ' and object_id>0 and name like ' '$%' '' declare nvarchar ( max) = - Author: Kamil Sáček - Create date: - Description: Function for copying comany from one database to another - = CREATE PROCEDURE varchar( varchar( varchar( max)ĪS BEGIN - SET NOCOUNT ON added to prevent extra result sets from - interfering with SELECT statements. This SP do not need to be marked as system. This new script directly copy the data in one go, you do not need to save the script and execute it in second step. Because the first script I have released was “two step job” and it is too complicated to use it in some automated way, I have prepared this new script, which is only modification of the original.
