Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is a field in an index?
Message
 
 
À
18/06/2003 17:38:55
Gary Foster
Pointsource Consulting LLC
Chanhassen, Minnesota, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00801471
Message ID:
00801534
Vues:
16
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform