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=‘‘‘ [email protected]+‘‘‘‘ 如果引用的是数值,则只要加一对: ‘select * from tb where col=‘+ @intval +‘ and true‘ 如果引用的数值,且为语句结尾,则后面的单引号也不要:‘select * from tb where col=‘ [email protected]
时间: 2024-10-28 14:42:59