[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

create non clustered non unique index sql server 2005

Posted on 2011-02-24
7
Medium Priority
?
888 Views
Last Modified: 2012-05-11
Expert,

how to create non unique non clustered index? Is this correct?

CREATE NONCLUSTERED INDEX IX_SalesPerson_SalesQuota_SalesYTD
    ON Sales.SalesPerson (SalesQuota);
GO
Thanks,

Lynn
0
Comment
Question by:yrcdba7
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 18

Expert Comment

by:sventhan
ID: 34971982
CREATE NONCLUSTERED INDEX IX_SalesPerson_SalesQuota_SalesYTD
    ON Sales.SalesPerson (SalesQuota);
GO

or

CREATE INDEX IX_SalesPerson_SalesQuota_SalesYTD
    ON Sales.SalesPerson (SalesQuota);
GO
0
 
LVL 18

Expert Comment

by:sventhan
ID: 34971991
Syntax:

create index index_name on table(columnname)
0
 
LVL 15

Expert Comment

by:Aaron Shilo
ID: 34972098
yes your syntax is currect
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:yrcdba7
ID: 34972101
Thank you,

how about clustered non-unique index?
0
 
LVL 41

Accepted Solution

by:
Sharath earned 2000 total points
ID: 34972136
Did you check the msdn? http://msdn.microsoft.com/en-us/library/ms188783.aspx
C. Creating a unique nonclustered index

The following example creates a unique nonclustered index on the Name column of the Production.UnitMeasure table. The index will enforce uniqueness on the data inserted into the Name column.

Copy
USE AdventureWorks2008R2;
GO
IF EXISTS (SELECT name from sys.indexes
             WHERE name = N'AK_UnitMeasure_Name')
    DROP INDEX AK_UnitMeasure_Name ON Production.UnitMeasure;
GO
CREATE UNIQUE INDEX AK_UnitMeasure_Name 
    ON Production.UnitMeasure(Name);
GO

Open in new window

If you don't mention UNIQUE, it won't create UNIQUE index.
0
 
LVL 15

Expert Comment

by:Aaron Shilo
ID: 34972266
you syntax will create a nonclustered nonunique index

create NONCLUSTERED index ABC_IDX on mytable(mycolumn)  = nonclustered nonunique

create UNIQUE  NONCLUSTERED index ABC_IDX on mytable(mycolumn)  = nonclustered unique

create CLUSTERED index ABC_IDX on mytable(mycolumn)  = clustered nonunique

create unique  CLUSTERED index ABC_IDX on mytable(mycolumn)  = clustered unique
0
 

Author Comment

by:yrcdba7
ID: 34973918
Thankyou, Lynn
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question