Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is a field in an index?
Message
 
 
To
18/06/2003 17:38:55
Gary Foster
Pointsource Consulting LLC
Chanhassen, Minnesota, United States
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00801471
Message ID:
00801534
Views:
15
The code below will return the list of index names with specified column in it. you can adapt it to your needs.
IF object_id('tempdb..#mytable') IS NOT NULL
	DROP TABLE #mytable
DECLARE @table varchar(128), @column varchar(128)
SET @table = 'authors'
SET @column = 'au_id'
USE pubs
CREATE TABLE #mytable (
	index_name sysname, 
	index_description varchar(210),
	index_keys nvarchar(2078)  )
INSERT #mytable EXEC sp_helpindex authors
SELECT index_name FROM #mytable 
	WHERE ' ' + index_keys + ',' LIKE '% ' + @column + ',%'
IF object_id('tempdb..#mytable') IS NOT NULL
	DROP TABLE #mytable
>Does anyone know how to determine if a field from a SQL Server table is part of an index on that table? I want to know in order to prevent a possible LONG query that's not using an indexed field. I have been studying the system tables, but can't seem to figure it out how to determine that fact. Thanks
>
>Gary
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform