SQL Server - How to copy table's indexes from one database to another

SQL Server - How to copy table's indexes from one database to another

Post by ABO » Wed, 06 Feb 2002 20:10:28



Hi,
I am using SQL Server into my application. I need to copy a database table
and its indexes from one db to another db. To copy table structure I am
using SELECT INTO statement. Is there any way to copy indexes using T-SQL?

Thanks in advance.

Vijay

 
 
 

SQL Server - How to copy table's indexes from one database to another

Post by Narayana Vyas Kondredd » Wed, 06 Feb 2002 21:42:55


YOu need the T-SQL CREATE INDEX command to create indexes. It's a good
practice to save your original index creating scripts, and run them when and
where needed.

You can probably use DTS instead of SELECT INTO
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/


Quote:> Hi,
> I am using SQL Server into my application. I need to copy a database table
> and its indexes from one db to another db. To copy table structure I am
> using SELECT INTO statement. Is there any way to copy indexes using T-SQL?

> Thanks in advance.

> Vijay


 
 
 

SQL Server - How to copy table's indexes from one database to another

Post by Wayne Snyde » Wed, 06 Feb 2002 23:38:50


You may use SEM, go to the database, select tables, then select a table and
right click -> Generate SQL Scripts. Then run the script against the other
database.

--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC)
C*te, NC
(Please respond only to the newsgroups)

I support the Professional Association of SQL Server(PASS)


Quote:> Hi,
> I am using SQL Server into my application. I need to copy a database table
> and its indexes from one db to another db. To copy table structure I am
> using SELECT INTO statement. Is there any way to copy indexes using T-SQL?

> Thanks in advance.

> Vijay

 
 
 

SQL Server - How to copy table's indexes from one database to another

Post by Xiaoyu Li [M » Thu, 07 Feb 2002 00:01:53


If you want to transfer both data and schema (table schema and indexes),
you can use SQL 7.0/2000 DTS tool to export data from one server to
another, just need to choose the option "transfer objects" instead of the
default "transfer tables", so that indexes will be transfered as well.

Xiaoyu Li
Microsoft SQL Server Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure?  For information about the Strategic Technology Protection
Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.