句
一、
declare @strSql nvarchar(200)
set @strSql= ' ' 'PWA ' ', ' 'PWC ' ', ' 'PWB ' ', ' 'PWX ' ' '
select DISTINCT ProductType from MyTestTable where PackageType in (@strSql)
行後,。(然,MyTestTable表是有的)
2、
set @strSql= 'select ………… '
declare my_cur cursor scroll
for
exec sp_executesql @strSql
句提示法,不知如何。
多
[解决办法]
--1, try
declare @strSql nvarchar(200)
set @strSql= ' ' 'PWA ' ', ' 'PWC ' ', ' 'PWB ' ', ' 'PWX ' ' '
exec( 'select DISTINCT ProductType from MyTestTable where PackageType in ( '+@strSql+ ') ')
[解决办法]
问题1楼主的语句为:如下语句是没有问题,表里应该是没有这个条件的资料
执行一下下面语句有结果就有数据,没有表里就没有数据
select DISTINCT ProductType from MyTestTable where PackageType in ( 'PWA ', 'PWC ', 'PWB ', 'PWX ' )
[解决办法]
set @strSql= 'declare my_cur cursor scroll for select ………… '
exec sp_executesql @strSql
这样看看
[解决办法]
create table #tmptb(testdata datetime)
insert #tmptb(testdata) exec(@Sql)