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 VIDEOS
 
 
SQL E/BOOKS   WORLD, USA & SQL NEWS   FORMAT
SCRIPTS SQL 2005 SQL 2008 ARTICLES
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
SQL 2016 DESIGN & PROGRAMMING
 
 
 
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