Introduction:
Here I will explain how to create index on column in sql server 2008 or create index on multiple columns in sql server or create index on table in sql server 2008 with example.
Here I will explain how to create index on column in sql server 2008 or create index on multiple columns in sql server or create index on table in sql server 2008 with example.
Description:
In
previous articles I explained SQL
Server change identity column value, replace
multiple spaces with single space in sql, reseed
identity column value in sql server, get
only month and year from date in sql server, substring
function in SQL server and many articles relating to SQL server. Now I will explain how
to create index on column in sql server 2008.
Syntax to Create Index
CREATE INDEX
indexname ON Tablename(columnname)
|
Example:
CREATE INDEX
IC_Userid ON UserDetails(UserId)
|
If you want to create nonclustered index on table we
need to write the syntax like as shown below
Syntax to Create NonClustered Index on Column
CREATE NONCLUSTERED
INDEX indexname ON
Tablename(columnname)
|
Example:
CREATE NONCLUSTERED
INDEX NC_Userid ON
UserDetails(UserId)
|
If we want to create index on multiple columns at a
time we need to write the query like as shown below
If we want to create index on multiple columns at a time we need to write the query like as shown below
Syntax to Create Index on Multiple
Columns
CREATE INDEX
IC_Userid ON UserDetails(Col1,Cpl2)
|
Example:
CREATE INDEX
IC_Userid ON UserDetails(UserId,UserName)
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
1 comments :
nice easy
Note: Only a member of this blog may post a comment.