if you are using ADO, you can use Recordset's NextRecordset methodSet recordset2 = recordset1.NextRecordset( RecordsAffected )if you are using ADO.NET, DataReader has a NextResult method
调试欢乐多
,case when h.id is not null then 'PK' else '' end as primarykey
,type_name(b.xusertype) + case when b.colstat & 1 = 1 then '[ID(' + convert(varchar,ident_seed(a.name)) + ',' + convert(varchar,ident_incr(a.name)) + ')]' else '' end as type
,b.length
,case b.isnullable when 0 then 'N' else 'Y' end as [isnull]
,isnull(e.text,'') as [default]
,isnull(c.value,'') as descript
from sysobjects a,syscolumns b
left outer join sysproperties c on b.id = c.id and b.colid = c.smallid
left outer join syscomments e on b.cdefault = e.id
left outer join (select g.id,g.colid from sysindexes f,sysindexkeys g where f.id = g.id and f.indid = g.indid and f.indid > 0 and f.indid < 255 and (f.status & 2048)<>0) h on b.id = h.id and b.colid = h.colid
where a.id = b.id
and a.id = object_id('titles') --tablename改成你要导出的表的名称
order by b.colid
Dim cmd As New ADODB.Command
Dim rs As ADODB.Recordset Cmd.ActiveConnection = "DSN=MySamples;UID=sa"
Cmd.CommandText = "MyNextProc"
Cmd.CommandType = adCmdStoredProcSet rs = Cmd.Execute()
While Not rs Is Nothing
If (Not rs.EOF) Then
Debug.Print rs(0)
End If
Set rs = rs.NextRecordset()
Wend
Sub test()
Dim iDb As New ADODB.Connection
Dim iRe As ADODB.Recordset
iDb.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=数据库名;Data Source=服务器名"
Set iRe = iDb.Execute("sp_help '表名或对象名'")
While iRe.State <> adStateClosed
Debug.Print "---------------------------------------------"
If iRe.EOF Then
Debug.Print "无记录"
Else
Debug.Print iRe.GetString
End If
Debug.Print "---------------------------------------------"
Set iRe = iRe.NextRecordset
Wend
End Sub