在VB中用如下代码试试,因为从代码看是否有可能不会返回任何值。
set rs=db.execute(sql)
if rs.state=1 then '记录集是否已打开
while not rs.eof
'处理记录集
wend
end if
set rs=db.execute(sql)
if rs.state=1 then '记录集是否已打开
while not rs.eof
'处理记录集
wend
end if
解决方案 »
- SQL Server 2005示例数据库的问题,AdventureworkstoGo
- sql server中,如何将诸如 "34元" 这个字符串变成数值 34 的方法?谢谢了.
- sql-存储过程中动态视图,为何存储过程中创建的视图中没有数据
- 求一SQL
- 求一条sql语句,想了几天没想出来
- 怎样写这样的对统计sql语句
- 求SQL语句高手帮忙,关于分割表字段的语句!!(在线等!!!)
- 请教如何让两台电脑上的SQL的数据库能同步更新!!!
- 安装sql server2000(sql server7.0)到配置ODBC时出错,不能安装?有谁碰到过?
- 请问如何将一个WORD文档存储到SQL Server数据库中,数据库中字段属性是Image还是什么?
- 用事件查看器在跟踪delete 或者update等语句时,提示"读取跟踪数据失败"
- 数据库设计 有关主键的问题!!!
With cmd
.ActiveConnection = con
.CommandType = adCmdStoredProc
.CommandText = "findjsdmgs"
.Parameters.Append .CreateParameter("@jsdm", adChar, adParamInput, 7, "具体数值")
.Parameters.Append .CreateParameter("@r1q", adChar, adParamInput, 7, "具体数值")
.Parameters.Append .CreateParameter("@r1z", adChar, adParamInput, 7, "具体数值")
End With
Set rs = cmd.Execute用命令对象试试
AS
set nocount on--add*************************************************************
if object_id('tempdb..##temp1') is not null
drop table ##temp1
if object_id('tempdb..##temp') is not null
drop table ##tempdeclare @sql varchar(8000)
declare @dwmc char(40)
select c.dwmc,a.gs,sum(a.sl)as sl ,convert(varchar(7),a.r1,120) as r1 into ##temp1 from slk a left join gs b on a.gs=b.gs left join dwxx c on b.jsdm1=c.jsdm
where convert(varchar(7),r1,120)>=@r1q and convert(varchar(7),r1,120)<=@r1z and b.jsdm1=@jsdm
group by a.gs,convert(varchar(7),a.r1,120),c.dwmcif object_id('tempdb..##temp1') is not null
if exists(select top 1 * from ##temp1)
begin
select @dwmc=dwmc from ##temp1
if @dwmc is not null
begin
set @sql = 'select dwmc as 单位名称,gs as 给水号,'
select @sql = @sql + 'sum(case r1 when '''+r1+'''
then sl else 0 end) as '''+r1+''' ,' from (select distinct r1 from ##temp1 ) as a
select @sql = left(@sql,len(@sql)-1)
exec(@sql + 'into ##temp from ##temp1 group by gs,dwmc')
set nocount on
select * from ##temp
end
end
set nocount offGO