Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 12890

OBJECT_ID for a PK or Index

$
0
0

Hi friends,

With a need for the first time to check if a PK and an Index exists before dropping and re-creating the same need your help.

IF OBJECT_ID(N'PK_LMT', N'PK') IS NOT NULL SELECT 1 (does not work and reflects Command(s) completed successfully)
IF OBJECT_ID('PK_LMT', 'PK') IS NOT NULL SELECT 1 (does not work and Command(s) completed successfully)

While:

SELECT * FROM SYS.objects WHERE NAME = 'PK_LMT' (does reflect the same)

Similarly how to check if an index (named IX_LGUF_DT_CUST) exists? Is it only to check from sys.indexes?

Thanks for all your help.



Viewing all articles
Browse latest Browse all 12890

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>