How To Drop Existing Indexes in MS SQL Server?
Submitted by: AdministratorFor some reason, if you want remove an existing index, you can use the DROP INDEX statement with following syntax:
CREATE INDEX table_name.index_name
The tutorial exercise below shows you how to remove the index "ggl_links_id":
USE GlobalGuideLineDatabase;
GO
SELECT * FROM sys.indexes WHERE object_id = (
SELECT object_id FROM sys.tables WHERE name = 'ggl_links'
);
GO
<pre>object_id name index_id type_desc is_unique
--------- ------------- -------- ---------- ---------
421576540 NULL 0 HEAP 0
421576540 ggl_links_id 2 NONCLUSTERED 0
421576540 ggl_links_url 3 NONCLUSTERED 0</pre>
DROP INDEX ggl_links.ggl_links_id;
GO
SELECT * FROM sys.indexes WHERE object_id = (
SELECT object_id FROM sys.tables WHERE name = 'ggl_links'
);
GO
<pre>object_id name index_id type_desc is_unique
--------- ------------- -------- ---------- ---------
421576540 NULL 0 HEAP 0
421576540 ggl_links_url 3 NONCLUSTERED 0</pre>
Submitted by: Administrator
CREATE INDEX table_name.index_name
The tutorial exercise below shows you how to remove the index "ggl_links_id":
USE GlobalGuideLineDatabase;
GO
SELECT * FROM sys.indexes WHERE object_id = (
SELECT object_id FROM sys.tables WHERE name = 'ggl_links'
);
GO
<pre>object_id name index_id type_desc is_unique
--------- ------------- -------- ---------- ---------
421576540 NULL 0 HEAP 0
421576540 ggl_links_id 2 NONCLUSTERED 0
421576540 ggl_links_url 3 NONCLUSTERED 0</pre>
DROP INDEX ggl_links.ggl_links_id;
GO
SELECT * FROM sys.indexes WHERE object_id = (
SELECT object_id FROM sys.tables WHERE name = 'ggl_links'
);
GO
<pre>object_id name index_id type_desc is_unique
--------- ------------- -------- ---------- ---------
421576540 NULL 0 HEAP 0
421576540 ggl_links_url 3 NONCLUSTERED 0</pre>
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Select Some Specific Rows from a Table in MS SQL Server? |
☺ | How To Start SQL Server Browser Service? |
☺ | How To Execute the Cursor Queries with "OPEN" Statements? |
☺ | How To Test ODBC DSN Connection Settings? |
☺ | PHP MSSQL - How To Display a Past Time in Days, Hours and Minutes? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |