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

解决方案 »

  1.   

    ??sp_help @objectname返回的结果集不是固定的,根据OBJECT的属性不同而不同,如果通过ADO的RECORDSET和DATAREADER处理是否不太方便,我想还是自己写SP从系统表里返回比较合理。
      

  2.   

    select rtrim(b.name) as colname
    ,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
      

  3.   

    select d.name,a.name ,b.name ,a.length, a.isnullable from syscolumns a, systypes b,sysobjects d where a.xtype=b.xusertype and a.id=d.id and d.xtype='U'
      

  4.   

    如果你坚持用sp_help:ADO的NextRecordset属性
    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
      

  5.   

    用ADO
    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