Michael Phelps
Michael Phelps

Reputation: 3591

Why does object_id always return null?

SELECT object_id('dbo.groups','U'); //NULL 

enter image description here

Upvotes: 2

Views: 3218

Answers (1)

Derek Tomes
Derek Tomes

Reputation: 4007

OBJECT_ID returns NULL on error.

A user can only view the metadata of securables that the user owns or on which the user has been granted permission. This means that metadata-emitting, built-in functions such as OBJECT_ID may return NULL if the user does not have any permission on the object.

For more information, see Metadata Visibility Configuration.

Upvotes: 6

Related Questions