[dba-SQLServer] Difference between views and queries

MartyConnelly martyconnelly at shaw.ca
Sun Jul 11 15:42:41 CDT 2004


jwcolby wrote:

>Can anyone explain the difference between a view and a query?  Views use a
>query, plus the view keyword.  I have a couple of books that I have read the
>chapter on Views, but I so far haven't managed to "get" why you wouldn't
>just use the query itself instead of turning it into a view.
>
>  
>
Interestingly ADOX catalogs describes Access queries as Type  VIEW

Sub testa()
'Declare a reference to an ADOX Catalog Object
Dim cat1 As New ADOX.Catalog
Dim cnn1 As ADODB.Connection
Dim c As Object
Dim cn As ADODB.Connection
Set cnn1 = New ADODB.Connection

cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=C:\Program Files\Microsoft 
Office\Office\Samples\Northwind.mdb;"
          
'cnn1.Open "Provider=sqloledb;" & _
'           "Data Source=(local);" & _
'           "Initial Catalog=Pubs;" & _
'           "User Id=sa;" & _
'           "Password="

'Open an ADO Connection Object
'Assign the connection to the catalog
cat1.ActiveConnection = cnn1

'Loop through the tables in the catalog
Dim str1 As String
Dim tbl1 As ADOX.Table
For Each tbl1 In cat1.Tables
Debug.Print tbl1.Type & "-"; tbl1.Name
  If tbl1.Type = "TABLE" Then
     str1 = str1 & tbl1.Name & vbCr
    
  End If
Next
Debug.Print str1

End Sub
 

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the dba-SQLServer mailing list