anushahanna
asked on
sysobjects vs all_objects
select * from sys.sysobjects where user_name(uid) is null and type = 'U'
brings back 54 records
select * from sys.all_objects where principal_id is null and type = 'U'
brings 396 records.
Both should bring back the tables in the database; why the diff and what is the difference?
brings back 54 records
select * from sys.all_objects where principal_id is null and type = 'U'
brings 396 records.
Both should bring back the tables in the database; why the diff and what is the difference?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK. then when only will it have a valid principal_id: even for dbo it is NULL
create database test
go
use test
create table test(test int)
select * from sys.all_objects where type = 'u' and principal_id is not null
use master
drop database test
create database test
go
use test
create table test(test int)
select * from sys.all_objects where type = 'u' and principal_id is not null
use master
drop database test
ASKER
the only alternative for being owned by the schema is being owned by dbo, right?
I have
select * from sys.all_objects where principal_id is not null
return 0 rows back. Does that mean all objects are not owned by the schema?