开发者

How can i import indexes into ms SQL Server?

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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜