I need to enumerate the tables and fields in a SQL server 7.x database which I connect to thru ODBC. I have little support from my DBA so stored procedures are out of the question. Is there any way to do this with SQL or VB / VBA?
From jsnulf... I found answer using ADO instead of DAO....<br><br>This example uses the OpenSchema method to display the name and type of each table in the Pubs database.<br><br>Public Sub OpenSchemaX()<br><br> Dim cnn1 As ADODB.Connection<br> Dim rstSchema As ADODB.Recordset<br> Dim strCnn As String<br> <br> Set cnn1 = New ADODB.Connection<br> strCnn = "Provider=sqloledb;" & _<br> "Data Source=srv;Initial Catalog=Pubs;User Id=sa;Password=; "<br> cnn1.Open strCnn<br> <br> Set rstSchema = cnn1.OpenSchema(adSchemaTables)<br> <br> Do Until rstSchema.EOF<br> Debug.Print "Table name: " & _<br> rstSchema!TABLE_NAME & vbCr & _<br> "Table type: " & rstSchema!TABLE_TYPE & vbCr<br> rstSchema.MoveNext<br> Loop<br> rstSchema.Close<br> <br> cnn1.Close<br> <br>End Sub<br><br>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.