create procedure proc_SelectDynamic
@Id int, -- ID
@LbId int, -- 类别ID
@GetField nvarchar(200) -- 获取字段名
AS
declare @sql nvarchar(300), @param nvarchar(500)
set @sql = 'SELECT ' + @GetField + ' FROM TEST WHERE ID = @ID AND LBID = @LBID '
set @param = '@ID int, @LbId int'
exec sp_executesql @sql, @param, @id, @lbid