- 论坛徽章:
- 0
|
create procedure sp_pb60table
@table_name varchar(32) = null,
@table_owner varchar(32) = null,
@table_qualifier varchar(32) = null,
@table_type varchar(100) = null
as
declare @type1 varchar(3)
if @table_type is null
begin
select @type1 = \'SUV\'
end
else
begin
select @type1 = null
if (charindex(\"\'SYSTEM TABLE\'\", @table_type) != 0)
select @type1 = @type1 + \'S\'
if (charindex (\"\'TABLE\'\", @table_type) != 0)
select @type1 = @type1 + \'U\'
if (charindex (\"\'VIEW\'\", @table_type) != 0)
select @type1 = @type1 + \'V\'
end
if @table_name is null
begin
select @table_name = \'%\'
end
else
begin
if (@table_owner is null) and (charindex(\'%\', @table_name) = 0)
begin
if exists (select * from sysobjects where uid = user_id() and
name = @table_name and (type = \'U\' or type = \'V\' or type = \'S\'))
begin
select @table_owner = user_name()
end
end
end
if @table_owner is null
select @table_owner = \'%\'
select o.name, o.id, o.type, o.uid, user_name(o.uid)
from sysusers u, sysobjects o
where o.name like @table_name
and user_name(o.uid) like @table_owner
and charindex(substring(o.type,1,1),@type1) != 0
and u.uid = user_id()
and (suser_id() = 1
or o.uid = user_id()
or ((select max(((sign(uid) * abs(uid-16383)) * 2) + (~(protecttype/2)))
from sysprotects p
where p.id = o.id
and (p.uid = 0
or p.uid = user_id()
or p.uid = u.gid)
and (action in (193,224)))&1) = 1) |
|