发布网友 发布时间:2022-04-09 04:30
共3个回答
懂视网 时间:2022-04-09 08:52
PROC Test_GetCollegeInfo @type int AS BEGIN DECLARE @where nvarchar(800),@v int,@sql nvarchar(max) IF @type>2 Begin SET @where=‘AND colleges.id=‘+cast(@type AS varchar(100)) END ELSE BEGIN SET @where=‘‘ END SET @sql=‘ SELECT * FROM collegeMajor INNER JOIN MajorsType ON collegeMajor.majorType=MajorsType.id INNER JOIN colleges ON colleges.id=collegeMajor.collageID WHERE 1=1 ‘+@where EXEC (@sql) End
Sql用变量拼语句
标签:
热心网友 时间:2022-04-09 06:00
创建:热心网友 时间:2022-04-09 07:18
动态sql拼接,大致上是这样: