Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Createa table like a existing table?
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


Report this thread to moderator Post Follow-up to this message
Old Post
SSG
12-27-05 08:23 AM


Re: Createa table like a existing table?
SSG (ssg14j@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, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Report this thread to moderator Post Follow-up to this message
Old Post
Erland Sommarskog
12-27-05 08:23 AM


Re: Createa table like a existing table?
On Tue, 27 Dec 2005 08:13:25 +0000 (UTC), Erland Sommarskog
<esquel@sommarskog.se> wrote:

>SSG (ssg14j@gmail.com) writes: 
>
>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.

Report this thread to moderator Post Follow-up to this message
Old Post
Steve Jorgensen
12-27-05 08:23 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 04:06 AM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006