i have to find existence of an index and stats.

rajesh yadav 171 Reputation points
2021-08-20T05:27:45.98+00:00

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
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,361 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,601 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. Seeya Xi-MSFT 16,461 Reputation points
    2021-08-20T07:28:57.643+00:00

    Hi @rajesh yadav ,

    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.

    0 comments No comments