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…
例如:String sql = "select * from user where username='" + username + "' and password ='" + password + "' ";执行的时候自动就把变量转换为字符串类型,“”表示字符串,‘’是SQL的字符串和字符两个双引号和变量拼接在一起,会吧变量转化为字符串执行SQL的时候是这样的select * from user where username='' and pa…
来源自http://vyaskn.tripod.com/code.htm#inserts SET NOCOUNT ON GO PRINT 'Using Master database' USE master GO PRINT 'Checking for the existence of this procedure' IF (SELECT OBJECT_ID('sp_generate_inserts','P')) IS NOT NULL --means, the procedure alread…