問題一、
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
這句話提示語法錯誤,不知應該如何寫。
多謝
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
這句話提示語法錯誤,不知應該如何寫。
多謝
解决方案 »
- 在sql2000里,如何update timedate
- 存储过程中的IF
- 数据库语句条件判断问题
- libin_ftsafe(子陌红尘)大哥 请进
- 急问,怎样将大批xml文件进行统计,将具有相同汉字数目的xml文件数目统计出来
- 数据表设计问题,表中有一个状态字段,分“未审核,已审核,已认证”三个状态,用-1,0,1三个数字表示好还是直接存储三个状态
- 一个表不该被反复3次以上不断的重复join的?
- sql2000中的数据怎么会突然变了??太奇怪了!!!
- cas()函数 和 convert()函数的区别是什么
- 急sql server union 查询问题
- 一道排序题,高手请指教
- 一个复杂的查询语句,麻烦高手能帮忙解释一下,万分感谢
declare my_cur cursor scroll
for
exec sp_executesql @strSql
游标不能这样用
declare @strSql nvarchar(200)set @strSql='PWA,PWC,PWB,PWX' select DISTINCT ProductType from MyTestTable where charindex(','+PackageType+',',','+@strSql+',')>0
給定一個條件字符串,如:set @strSql='aa','bb','cc'
set @strSql='select testdata from testtable where id in('+@strSql+')'
怎麼能獲得這個@strSql的招待結果的遊標
declare @strSql nvarchar(200)
set @strSql=' ''PWA'',''PWC'',''PWB'',''PWX'' '
exec('select DISTINCT ProductType from MyTestTable where PackageType in ('+@strSql+')')
执行一下下面语句有结果就有数据,没有表里就没有数据
select DISTINCT ProductType from MyTestTable where PackageType in ( 'PWA','PWC','PWB','PWX' )
exec sp_executesql @strSql
这样看看
for
select * from tbName
insert #tmptb(testdata) exec(@Sql)
declare my_cur cursor scroll
for select testdata from #tmptb
exec('select DISTINCT ProductType from MyTestTable where PackageType in ('+@strSql+')')