Home > Archive > MS SQL Server MSEQ > August 2005 > RE: Having a stored procedure copy tables & also preserve indexing









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: Having a stored procedure copy tables & also preserve indexing
Vishal Parkar

2005-08-18, 8:24 pm

actually it creates identity column but not PRIMARY KEY, UNIQUE,
FOREIGN KEY, CHECK, NOT NULL, DEFAULT constraints

--Vishal.

"Vishal Parkar" wrote:
[color=darkred]
> SELECT ... INTO <tablename> doesn't create any of the PRIMARY KEY, UNIQUE,
> FOREIGN KEY, CHECK, NOT NULL constraints and doesn't define DEFAULT and
> IDENTITY column properties for the new table.
>
> You will have to write seperate statements into your stored procedure to
> create them.
>
> --Vishal.
>
>
> "Peter S." wrote:
>
Peter S.

2005-08-18, 8:24 pm

As I previously stated I *do* understand that SELECT INTO does not create
PRIMARY KEYS etc. I was hoping there would be an alternate way to do
a full blown copy that includes creation of the INDEXES, KEYS etc. For
example there is a stored procedure called SP_RENAME. I was hoping there was
an SP_FULLCOPY or something that might get me what I was looking for.

Is there a way I can automatically pull (from my stored procedure) the
ALTER commands to create the keys etc and execute them on the fly?
That would do it. I have looked into SQL-DMO and Automatically generating
scripts through Enterprise Manager but that doesn't get me what I need.
I have over 80 tables to deal with and would like to create the necessary
ALTER
commands automatically....

Any helpful information you might be able to supply would be GREATLY
appreciated!

-Peter

"Vishal Parkar" wrote:
[color=darkred]
> actually it creates identity column but not PRIMARY KEY, UNIQUE,
> FOREIGN KEY, CHECK, NOT NULL, DEFAULT constraints
>
> --Vishal.
>
> "Vishal Parkar" wrote:
>
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com