是程序还是存储过程呢?

jacky_hou 2004-02-17 11:48:18
存储过程为:
create procedure Hu_test_hu
as
select A.e_tax_no,A.mac_pz,A.pcno,B.offtype into #tmpMac_zj from
(select e_tax_no,mac_pz,(case when charindex(',',mac_pz)>0 then left(mac_pz,charindex(',',mac_pz)-1) else mac_pz end) as PCno from mac_zj)
A,op_table B where a.e_tax_no=b.e_tax_no and a.e_tax_no='440301723000442'
if exists
(select 1 from kf,#tmpMac_zj where kf.type=#tmpMac_zj.pcno)
begin
select top 1 A1.equipment as pc,B1.pcno,B1.mac_pz,B1.offtype from kf A1,#tmpMac_zj B1 where b1.pcno=a1.type
end
else
select top 1 pcno,pcno,mac_pz,offtype from #tmpMac_Zj
'=====================
vb程序为
Dim Rs As ADODB.Recordset
Dim cmd As ADODB.Command
Dim cn As New ADODB.Connection
Private Sub Command1_Click()
Set cn = New ADODB.Connection
cn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;password=sqlserveradministrator;Initial Catalog=cis;Data Source=192.168.0.100"
Set Rs = New ADODB.Recordset
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = cn
.CommandType = adCmdStoredProc
.CommandText = "hu_test_hu"
.Parameters.Refresh
End With
With Rs
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockReadOnly
.Open cmd
Debug.Print .RecordCount
End With
End Sub
...全文
69 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧