开发者

dynamically create table statement in sql

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜