DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
SITE SEARCH SQLUSA.com HEADLINES NEWS
SQL E/BOOKS   SQL 2014 PROGRAMMING   DOWNLOADS
SCRIPTS SQL 2005 SQL 2008 ARTICLES
SQL JOBS TWITTER FORMAT VIDEOS
How to find unique indexes in a database?

The following Microsoft SQL Server T- SQL query will list unique indexes in a database:

USE AdventureWorks2008;

 

SELECT IndexName = i.Name,

       SchemaName = schema_name(schema_id),

       TableName = object_name(o.object_id)

FROM   sys.indexes i

       JOIN sys.objects o

         ON i.object_id = o.object_id

WHERE  is_primary_key = 0

       AND is_unique = 1

       AND o.object_id IN (SELECT object_id

                           FROM   sys.objects

                           WHERE  TYPE = 'U')

ORDER  BY SchemaName,

          TableName,

          IndexName; 

------------

 

-- Create a UNIQUE index on the Product table

CREATE UNIQUE NONCLUSTERED INDEX [AK_Product_ProductNumber]

ON [Production].[Product]

(

      [ProductNumber] ASC

);

------------ 

 

 

Exam Prep 70-461
Exam 70-461
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE