日期:2014-05-17 浏览次数:20601 次
if object_id('table1') is not null
drop table table1
go
create table table1(
ward_no int
)
insert into table1
select 10206
go
declare @sql nvarchar(20)
--自己改变,看看结果
set @sql = '10206'
--选择消息选项卡,看看sql语句,你就明白
print('select * from table1 where ward_no = '+@sql+ ' and 1=1')
print('select * from table1 where ward_no = ''+@sql+ '' and 1=1')
print('select * from table1 where ward_no = '''+@sql+ ''' and 1=1')
--执行
--exec('select * from table1 where ward_no = '''+@sql+ ''' and 1=1')