declare @letter char(1)
declare @sql varchar(299)
set @letter= 'a '
set @sql= 'select * from syinfo_subzone '
set @[email protected]+ ' where sz_letter =cast(@letter as char(1)) '
exec (@sql)
服务器: 消息 207,级别 16,状态 3,行 1
列名 'a ' 无效。
------解决方案--------------------
declare @letter char(1)
declare @sql varchar(299)
set @letter= 'a '
set @sql= 'select * from syinfo_subzone '
set @[email protected]+ ' where sz_letter = ' ' ' +cast(@letter as char(1)) + ' ' ' '
exec (@sql)
------解决方案--------------------
--try
declare @letter char(1)
declare @sql varchar(299)
set @letter= 'a '
set @sql= 'select * from syinfo_subzone '
set @[email protected]+ ' where sz_letter =cast( '[email protected]+ ' as char(1)) '
exec (@sql)
------解决方案--------------------
--试试
declare @sql varchar(299)
set @sql= 'declare @letter char(1) set @letter= ' 'a ' ' select * from syinfo_subzone where sz_letter =cast(@letter as char(1)) '
exec (@sql)
------解决方案--------------------
这样看看:
declare @letter char(1)
declare @sql varchar(299)
set @letter= 'a '
set @sql= 'select * from syinfo_subzone '
set @[email protected]+ ' where sz_letter = '[email protected]
exec (@sql)