Collections:
Creating an Index for Multiple Columns in SQL Server
How To Create an Index for Multiple Columns in SQL Server?
✍: FYIcenter.com
An index for multiple columns works similarly to a sorting process on multiple columns. If an index is defined for two columns, the index key is composed by values from those two columns.
A multi-column index will be used to speed up the search process based on the same columns in the same order as the index definition. For example, if you define an index called "combo_index" for "url" and "counts". "combo_index" will be used only when searching or sorting rows by "url" and "counts".
The tutorial exercise below shows you how to create an index for two columns:
-- Create an index for two columns CREATE INDEX combo_index ON fyi_links (url, counts); GO -- View indexes EXEC SP_HELP fyi_links; GO index_name index_description keys ----------------- -------------------------- ---- fyi_links_created nonclustered located on PRIMARY created fyi_links_url clustered located on PRIMARY url combo_index nonclustered located on PRIMARY url, counts -- Drop the index DROP INDEX fyi_links.combo_index; GO
⇒ Creating a Large Table with Random Data for Indexes in SQL Server
⇐ CREATE CLUSTERED INDEX - Adding Clustered Indexes in SQL Server
2016-11-13, 2994🔥, 0💬
Popular Posts:
How to execute statements in loops in SQL Server Transact-SQL? How to use WHILE ... loops? You can u...
How to check if two JSON values have overlaps using the JSON_OVERLAPS() function? JSON_OVERLAPS(json...
How To Change the Name of a Database User in SQL Server? If you want to change the name of an existi...
How To Recover a Dropped Index in Oracle? If you have the recycle bin feature turned on, dropped ind...
What Are Out-of-Range Errors with DATETIME values in SQL Server Transact-SQL? When you enter DATETIM...