select top 0 * into (要创建的表名)from 复制的表名
select top 0 * into t_apps123 from dbo.t_survey_results --此写法不能创建主键
-- 和上面的类似,可以创建主键
select * into CG from t_survey_results
where 1<>1 alter table CG
add constraint
PK_EXPORT_BA primary key (result_id)
本文介绍了一种使用SQL语句快速复制表结构的方法,并通过一个具体的例子展示了如何在复制过程中创建新的表及主键约束。这种方法适用于需要快速复制表结构并保持主键完整性的场景。
select top 0 * into (要创建的表名)from 复制的表名
select top 0 * into t_apps123 from dbo.t_survey_results --此写法不能创建主键
-- 和上面的类似,可以创建主键
select * into CG from t_survey_results
where 1<>1 alter table CG
add constraint
PK_EXPORT_BA primary key (result_id)

被折叠的 条评论
为什么被折叠?