select@rowcount=@@rowcount
if@rowcount=0
begin
select@rc=-1
printThereanouserobjectsindatabase!
return@rc
end
end
/***************************************************************************
*****/
/*Judgetheinputparameters,if@objectnameisnulland@usernameisnot
null*/
/*thenreturnallobjectsauthorizationwhererelation@username*/
/*iftheuserbelongtoagroup,sowemustaddthegroupauthorization*/
/***************************************************************************
*****/
if@rc=0and@usernameisnotnulland@objectnameisnull
begin
ifnotexists(select*fromsysuserswhere[uid]=user_id(@username)and
status0)
begin
select@rc=-2
printTheusernameisnotincludeinsysuserstable.
return@rc
end
select@rowcount=@@rowcount
if@rowcount=0
begin
select@rc=-6
print@objectname+havenotgrantauthorizationtoanyuser
return@rc
end
end
end
/***************************************************************************
*****/
/*Judgetheinputparameters,if@objectnameisnotnulland@usernameis
notnull*/
/*thenreturnoneobjectsauthorizationbyoneuser*/
/***************************************************************************
*****/
if@rc=0and@objectnameisnotnulland@usernameisnotnull
begin
ifnotexists(select*fromsysobjectswhere[id]=object_id(@objectname)
andxtypeS)
begin
select@rc=-7
printTheobjectnameisnotincludeinsysobjectstable.
return@rc
end
ifnotexists(select*fromsysuserswhere[uid]=user_id(@username)and
status0)
begin
select@rc=-8
printTheusernameisnotincludeinsysuserstable.
return@rc
end
select@rowcount=@@rowcount
if@rowcount=0
begin
select@rc=-10
print@username+havenotanyobjectsauthorization.
return@rc
end
end
end
end
go
execusp_getObjectAuthor