读书人

句,该如何处理

发布时间: 2012-01-29 21:39:32 作者: rapoo


一、
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)

读书人网 >SQL Server

热点推荐