set @InsertStr='INSERT INTO [dbo].[T_SchoolPercentMonth]([SchoolID],[MonthOfYear],[PercentNum]) VALUES('''+cast(@SchoolID as nvarchar)+''','''+convert(char(7),getdate(),20) +''','+cast(@PercentNum as nvarchar)+')'; 引用字符 加一对单引号. 'select * from tb wher
在SQL存储过程中给条件变量加上单引号,不加语句就会出问题,以下就是在存储过程中将条件where设置成了动态变化的,给where赋完值再和前面的语句拼接,再execute(SQL) ), )), )+''',sdate)<=0) and ' +' shopid='''+@shopid+''' and VenderID in ' +' (select vender from tableB where vendertype=''类型'' and shopid='''+@shopid+''')' --