有谁知道如何从2005 + sysobjects
(或其他)视图中获取等效的SQL Server 2000 uid
sys.objects
列?
我正在尝试转换此代码,因为我们正在删除所有sysobjects
引用。
DECLARE GETOBJECTS CURSOR FOR
SELECT NAME, UID FROM SYSOBJECTS
WHERE TYPE IN ('U','P')
AND UID <> 1
AND LOWER(RTRIM(NAME)) NOT LIKE 'PB%'
提前致谢,
凯文
答案 0 :(得分:2)
UID 是指对象所有者的用户ID ...
在SQL 2005和SQl 2008中,您可以在
中找到它sys.sysobjects
字段名称 UID
UID = 1是dbo用户。
因此,要使用例程和表视图并过滤掉dbo,请尝试以下代码
select Routine_name as Name, specific_schema as user
from INFORMATION_SCHEMA.ROUTINES
where specific_schema <> 'dbo'
UNION
select Table_name as Name, specific_schema as user
from INFORMATION_SCHEMA.TABLES
where specific_schema <> 'dbo'
答案 1 :(得分:0)
要获取不属于dbo
主体的所有对象,请执行以下操作:
select name, object_id
from sys.objects
where principal_id not in
(
select principal_id
from sys.database_principals
where name = 'dbo'
)