VB and VBA Users Source Code: Dropping/recreating and index
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Dropping/recreating and index
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Thursday, August 23, 2001
Hits:
738
Category:
Database/SQL/ADO
Article:
The following SQL is normally used to drop a table in SQL server: if object_id('MyTable') is not null drop table MyTable This SQL checks to see if the table exists before dropping it. However, indexs are stored in the sysindexes table not in the sysobjects table. So object_id will always return null for an index. To drop an index use the following SQL: IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('dbo.MyTable') AND name='MyIndex') drop index MyTable.MyIndex go
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder