January 13, 2017 at 9:43 am
Hi,
I need to copy the existing table schema of one database to another database. My idea is to create a table with following fields
[Code]
Use Production_Strudents;
GO
Create table ToBeArchived(
IdArchive int primary key identity(1,1),
table_name varchar(100),
table_owner varchar (100),
IsArchived bit default 0);
insert into ToBeArchived(tablet_name,table_owner,IsArchived)
Select 'Students','Student', 0 union all
Select 'Mark','Student', 0 union all
select 'Parents','dbo',0
[/code]
Basically, i need to clone a table(exact schema with all the constraints and etc) in different database "Archive" based on the IsArchived falg = 0 from Production_Strudents database. once the table create with exact schema then set IsArchived falg = 1. Please not that i don't want to copy the data.
I hope this is not new requirement as many of them would have done this in the past. Please post some sample script to get started on this.
January 13, 2017 at 2:24 pm
KGJ-Dev - Friday, January 13, 2017 9:43 AMHi,I need to copy the existing table schema of one database to another database. My idea is to create a table with following fields
[Code]
Use Production_Strudents;
GO
Create table ToBeArchived(
IdArchive int primary key identity(1,1),
table_name varchar(100),
table_owner varchar (100),
IsArchived bit default 0);
insert into ToBeArchived(tablet_name,table_owner,IsArchived)
Select 'Students','Student', 0 union all
Select 'Mark','Student', 0 union all
select 'Parents','dbo',0
[/code]Basically, i need to clone a table(exact schema with all the constraints and etc) in different database "Archive" based on the IsArchived falg = 0 from Production_Strudents database. once the table create with exact schema then set IsArchived falg = 1. Please not that i don't want to copy the data.
I hope this is not new requirement as many of them would have done this in the past. Please post some sample script to get started on this.
try Redgate SQLCompare
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply