471,573 Members | 1,127 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,573 software developers and data experts.

Createa table like a existing table?

SSG
Hai all

I am new to SLQ server. Can anyone tell me how to create a table that
should look like a existing table fields....

thanx

Dec 27 '05 #1
2 4576
SSG (ss****@gmail.com) writes:
I am new to SLQ server. Can anyone tell me how to create a table that
should look like a existing table fields....


You can do "SELECT * INTO newtbl FROM tbl WHERE 1 = 0". Beware though
that constraints, indexes and triggers are not copied. If you want that
you are better off scripting the table, which you can do by right-clicking
the table in the Object Broswer in Query Analyzer. Even better, have all
your source code under version control. Then copying is even easier.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 27 '05 #2
On Tue, 27 Dec 2005 08:13:25 +0000 (UTC), Erland Sommarskog
<es****@sommarskog.se> wrote:
SSG (ss****@gmail.com) writes:
I am new to SLQ server. Can anyone tell me how to create a table that
should look like a existing table fields....


You can do "SELECT * INTO newtbl FROM tbl WHERE 1 = 0". Beware though
that constraints, indexes and triggers are not copied. If you want that
you are better off scripting the table, which you can do by right-clicking
the table in the Object Broswer in Query Analyzer. Even better, have all
your source code under version control. Then copying is even easier.


Also note that in most cases where you would want to copy a table's design
within the same database, you'd probably be better off doing more
normalization instead.
Dec 27 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by me | last post: by
21 posts views Thread by Dan | last post: by
2 posts views Thread by Miguelito Bain | last post: by
1 post views Thread by Michael | last post: by
3 posts views Thread by Andrew Clark | last post: by
1 post views Thread by Greg | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.