开发者

Create mirror table using fields of original table

开发者 https://www.devze.com 2023-02-20 07:23 出处:网络
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 I

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消