再问一题
上次问道:
在存储过程中使用变量作为表名
如:
@a char(8)
as
select * from @a where ...
这个问题已有高手解答:
@a char(8)
as
exec('select * from '+@a+' where ...')
隆重收藏,接下来:
如果还有一变量,日期型,我没有通过,提示sql语句有错。错在那里?
@a char(8),
@date smalldatetime
as
exec('select * from '+@a+' where 日期='+@date)
使用cast转换函数后依然有错????