标签:blog ar sp div on c log r bs
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 where col=‘ + ‘abcd‘ + ‘ and true‘ 字符如果是变量值,再加两对单引号. ‘select * from tb where col=‘‘‘+ @colval+‘‘‘ and true‘ 如果字符是语句的结尾,加四个单引号.‘select * from tb where col=‘‘‘ +@colval+‘‘‘‘ 如果引用的是数值,则只要加一对: ‘select * from tb where col=‘+ @intval +‘ and true‘ 如果引用的数值,且为语句结尾,则后面的单引号也不要:‘select * from tb where col=‘ +@intval
insert当 sql语句里面有变量 为字符类型的时候 要3个单引号
标签:blog ar sp div on c log r bs
原文地址:http://www.cnblogs.com/muxueyuan/p/3994931.html