set @strsql = @strsql + 'select UserID,Role,(select typename from SysAuthorizationType where type=t.type) as typeTmp, '
set @strsql = @strsql + '(CASE WHEN State = 1 THEN ' + '''有效''' + ' ELSE ' + '''无效''' + ' END) AS StateTmp '
set @strsql = @strsql + 'FROM SysAuthorization t '
set @strwhere = ''
IF @UserID <> ''
BEGIN
set @strwhere = @strwhere + ' and (UserID LIKE ' + '''' + '%' + @UserID + '%' + '''' + ')'
END
IF @Type >0
BEGIN
set @strwhere = @strwhere + ' and Type = ' + CAST(@Type AS varchar(12))
END
if @strwhere <>''
BEGIN
set @strsql = @strsql + ' where ' + right(@strwhere, len(@strwhere)-4)
END
--按用户名排序
set @strsql = @strsql + ' ORDER BY Type,UserID'
exec (@strsql)
GO
文章来源于领测软件测试网 https://www.ltesting.net/