'Getting adSchemaTables from sql database

I'm trying to get all tables from sql database.

This is simple code

Public Sub TestAction()
Dim i As Long
Dim objRec As New ADODB.Recordset
Dim objConn As New ADODB.Connection
objConn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=xxxxxxxx;Data Source=xxxx;Use Procedure for Prepare=1;Auto Translate=True"
objConn.Open
Set objRec = objConn.OpenSchema(adSchemaTables)
i = 2
Do Until objRec.EOF
    sh1.Cells(i, 1).Value = "Table name: " & _
        objRec!TABLE_NAME & vbCr & _
        "Table type: " & objRec!TABLE_TYPE & vbCr
        i = i + 1
    objRec.MoveNext
Loop
If objConn.State = adStateOpen Then
    objConn.Close
Set objRec = Nothing
Set objConn = Nothing

End Sub

Im getting bunch of views but only two records view type 'TABLE' those two Table name: $ndo$dbconfig Table type: TABLE Table name: $ndo$dbproperty Table type: TABLE

What i am doing wrong. DataBase have a lot of tables.

vba


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source