I have the following query to check if there are any user defined objects in my SQL database.
DECLARE @testForEmpty BIT if exists (select top 1 null from dbo.sysobjects where (objectproperty(id, 'IsMsShipped') = 0)) set @testForEmpty = 0 else set @testForEmpty = 1
When I run this query as a specific user, I get testForEmpty = 1. This meant that the if exists call returns empty lines.
However, if I add the user as sysadmin, then I get the value of testFormEmpty equal to 0 and at least one row is selected.
I do not want to add the user to sysadmin. What is the minimum role / permissions that I must grant so that a selection from dbo.sysobjects returns the contents.
thanks
Venki source share