question

rajeshyadav-0048 avatar image
0 Votes"
rajeshyadav-0048 asked SeeyaXi-msft answered

i have to find existence of an index and stats.

hi,


is there any better way to find the existence of an index or stats then pls tell me.


IF NOT EXISTS (SELECT 1
FROM sys.indexes I
WHERE I.Name = 'XI_Status_Abb_ListDom' -- Index name
AND I.object_id = OBJECT_ID('ListDomain'))


IF NOT EXISTS ( SELECT * FROM sys.stats
WHERE name = 'stat_PipePipeIdParentPipeIdStatusLength'
AND object_ID = OBJECT_ID ('Pipe'))

yours sincerely






sql-server-generalsql-server-transact-sql
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OlafHelper-2800 avatar image
0 Votes"
OlafHelper-2800 answered

That's already the right way.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SeeyaXi-msft avatar image
0 Votes"
SeeyaXi-msft answered

Hi @rajeshyadav-0048,

The following method cannot be better and detailed, but it can be used for your reference.
Use sp_helpindex

Best regards,
Seeya


If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.