Create mirror table using fields of original table
I have some tables with a lot of columns that for every one of the table I have to create a "Mirror Table". This mirror contains the same columns of the original but there are bit type (except the Id). There isn't data to copy.
For example:
Table_Original
Id int
Field1 varchar
Field2 int
Field3 bit
...
Field50 varchar
Table_Mirror
Id [int] NOT NULL
Field1 [bit] NOT NULL DEFAULT ((0))
Field2 [bit] NOT NULL DEFAULT ((0))
Field3 [bit] NOT NULL DEFAULT ((0))
...
Field50 [bit] NOT NULL DEFAULT ((0))
Probably, in the future I have to开发者_如何学JAVA replicate the process in other databases, so manually is not an (inteligent) option. What is the best way to do it?
Thanks
Write an sql script with the appropriate CREATE TABLE
commands and run this script via SQLCMD
.
精彩评论