开发者

dynamically create table statement in sql

开发者 https://www.devze.com 2022-12-17 05:43 出处:网络
how to dynamically create a table with same 开发者_运维技巧columns as that of previous table. in sql select * into new_table from table where 1 = 0

how to dynamically create a table with same 开发者_运维技巧columns as that of previous table. in sql


select * into new_table from table where 1 = 0


select * into new_table from table

Thats works in SQL2005


I believe that both of the above answers will work, but since you don't need the data and you just need the format, I would do the following:

select * into new_table from table

TRUNCATE new_table; -- I'm sure you know this, but just in case someone is new and doesn't, truncate leaves the table structure and removes all of the data.

0

精彩评论

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