字段名用变量表示的存储过程代码 执行动态查询一定要用exec(“sql”)执行,
if @zx='selid'
begin
declare @sql varchar(400)
exec('select Id,DisciplineName,DisciplineType,DisciplineGrade,ContructGrade=(select ContructGrade from DisciplineContructGradeInfo where DisciplineContructGradeInfo.Id=DisciplineInfo.ContructGrade),ToDisciplineField,AcademicLeaderNO,DisciplineIntro from DisciplineInfo where '+@fild+ '=''' +@valu+'''')
end