[quoted text, click to view] On Fri, 11 Mar 2005 13:11:05 -0800, SusanB wrote:
>Hi,
>I can tell you why I want to copy a table without the data: I want to create
>a staging table to receive records from another source. A procedure will then
>read the records from the staging table and insert (or update if exists)
>record into original table. Is there a better way than you recommended in
>this post to do this?
>Susan
Hi Susan,
For a staging table, you typically want either a table with the same
structure but without most of the constraints, or (depending on the
quality of the imported data) a table with a different structure (e.g.
varchar or char for most columns, siince they need to be validated
before being converted to the correct datatype). Based on your question,
I assume that the quality of the imported data is high enough to warrant
the use of a copy of the table structure.
The best way, IMO, is to pull a copy of the CREATE TABLE script from
your source control system, change the name, remove the unneeded
constraints, then file it in your source control and run it.
Second best alternative would be a script that starts with a query like
I posted and then uses ALTER TABLE commands to add the constraints that
you do need for this staging table.
Best, Hugo
--