以下是在sybase使用游标的示例,因为当初使用这个示例消耗了一定的时间,先特做以记录
--查询直接授予用户的对象权限
DECLARE cur_DBName CURSOR FOR SELECT [name] FROM master..sysdatabases
go
BEGIN
DECLARE @temDBName VARCHAR(30)
DECLARE @v_sql VARCHAR(8000)
CREATE TABLE #tb_t1(dbName VARCHAR(50) NULL ,objectName VARCHAR(50) NULL,userName VARCHAR(50) NULL ,loginName VARCHAR(50) NULL ,action INT NULL ,protecttype INT ,grantor INT)
OPEN cur_DBName
FETCH cur_DBName into @temDBName
WHILE @@SQLSTATUS=0
BEGIN
SET @v_sql='insert into #tb_t1 select '''+@temDBName+''',d.name,b.name,c.name,a.action,a.protecttype,a.grantor from '+@temDBName+'..sysprotects a
inner join '+@temDBName+'..sysusers b on a.uid = b.uid
inner join master..syslogins c on b.suid = c.suid
inner join '+@temDBName+'..sysobjects d on a.id = d.id
'
exec(@v_sql)
FETCH cur_DBName into @temDBName
END
close cur_DBName
deallocate CURSOR cur_DBName
SELECT * FROM #tb_t1
DROP TABLE #tb_t1
END
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。