views:

18

answers:

2

I created a new databases , and added tables using the import data wizard. But the wizard din't create the indexed and constraint's on the table. How can I Import indexes?

+1  A: 

Just manually add indexes to your table

Here is an example from MSDN:

This example creates an index on the au_id column of the authors table.

SET NOCOUNT OFF
USE pubs
IF EXISTS (SELECT name FROM sysindexes 
      WHERE name = 'au_id_ind')
   DROP INDEX authors.au_id_ind
GO
USE pubs
CREATE INDEX au_id_ind
   ON authors (au_id)
GO

The other way you can do this is open the table in design mode management studio, highlight the field you want to index and look at the options at the top. One of them is for indexes and you can simply manually add it and give it a name right in management studio.

JonH
+1  A: 

If your source is also SQL Server, you should be able to run Tasks -> Generate Scripts and select "Script Indexes" in the list of options for the old database and execute the script on the new database with maybe a change in database name.

Andrew Flanagan
But I have already created the tables and added data. Using generate scripts there is not option to create indexes on already existing table.
Pinu
This would only work if your SOURCE was also a SQL Server database.
Andrew Flanagan
@Pinu, you would generate a script and then run it on the new database.
Abe Miessler