2

How can I find out if sp_addextendedproperty is available before trying to use it in a sql script?

I gather it's not available on Azure.

(I'm working on this bug, if you're interested).

2
  • Wouldn't TRY/CATCH work? Commented Apr 26, 2015 at 1:42
  • Also you say I don't want to just detect that it is azure in case microsft add/remove this proc from various versions of sql server in the future. Why not just not use extended properties in the first place? Commented Apr 26, 2015 at 15:48

1 Answer 1

4

Use OBJECT_ID to see of the object exists. The function will return NULL if not:

IF OBJECT_ID(N'sp_addextendedproperty', 'P') IS NOT NULL
    EXEC sp_addextendedproperty ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.