1. declare @test varchar(100) set @test='select * from test where test=''a''' -- ok 正确的赋值方式set @test='select * from test where test="a"'实际上是 select * from test where test="a" --sql 不支持"这个符号 set @test=select * from test where test='a' --这样的赋值方式时不行的 select * from test where test= 不是变量也不是字符2declare @s varchar(100) select @s = ' truncate table test' from sysobjects where xtype = 'U' and name != 'dtproperties'实际上只是 @s 为 truncate table test --当然是okselect @s = ' truncate table test from sysobjects where xtype = ''U'' and name != ''dtproperties'''实际上只是 @s 为 truncate table test from sysobjects where xtype = 'U' and name != 'dtproperties' 这样语句能执行才怪呢
declare @test varchar(100)
set @test='select * from test where test=''a''' -- ok 正确的赋值方式set @test='select * from test where test="a"'实际上是 select * from test where test="a" --sql 不支持"这个符号 set @test=select * from test where test='a' --这样的赋值方式时不行的 select * from test where test= 不是变量也不是字符2declare @s varchar(100)
select @s = ' truncate table test' from sysobjects where xtype = 'U' and name != 'dtproperties'实际上只是 @s 为 truncate table test --当然是okselect @s = ' truncate table test from sysobjects where xtype = ''U'' and name != ''dtproperties'''实际上只是 @s 为 truncate table test from sysobjects where xtype = 'U' and name != 'dtproperties' 这样语句能执行才怪呢