Re: create table statement On Mar 3, 6:06 pm, thetaamo...@gmail.com wrote:
> I need to create duplicates of certain tables.
> It woud be great if i can find the 'create table statement', in any of
> the system tables which the Create Table of the Object Browser in
> Query Analyzer users, so that i can just change the name and create a
> new table thus.
>
> Please help me find the Create Table statement available in the system
> tables
> thank you
You can't find the create table statement because it is not stored
anywhere, but there are other options. One option is to run select
into statement and add a where clause that will select no records at
all. For example the statement bellow will create a table that is
called CopyOfEmployees that has no records at all, but it has the same
structure as Employees table:
select * into CopyOfEmployees from Employees where 1=0
Notice that the select into statement will create a new table with
the same columns as the original table (name and data type) but it
will not create indexes and constraints.
Another option is to create a script from EM/QA or SSMS. If you'll
create the table in the same database, you'll need to rename all
constraints in the script. If you won't do it, the create table
statement will fail.
Adi |