For a bit of database-sanity checking code, I’d like to determine whether a particular object_id corresponds to an empty table.
Is there some way to (for instance) select count(*) from magic_operator(my_object_id) or similar?
I’d strongly prefer a pure-sql solution that can run on MS SQL server 2008b.
You can get a rough idea from
If you want guaranteed accuracy you would need to construct and execute a dynamic SQL string containing the two part object name. Example below though depending on how you are using this you may prefer to use
sp_executesqland return the result as an output parameter instead.