View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
PatK PatK is offline
external usenet poster
 
Posts: 96
Default SQL Query to Excel

Well..that helped part of the problem. I am now consistently getting 3 of the
120+ columns of data, in the table (there are about 6000 rows X 128 columns
per row). SO, that's a start. Is there some "max" that I am crashing in to
with that many columns of data? DOes it make any difference that this is a
sql view, vs a table?

Thanks again, Rob and Gary's Student :-)

patk

"Gary''s Student" wrote:

Try:

Sub WSPopulate()
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strWhere As String

Set con = New ADODB.Connection
con.Open "Driver={SQL Server};Server=GVS00534\node1;Database=mydb;"
strWhere = "SELECT * FROM dbo.application WHERE Owner_L2 = 'sbcorg'"

Set rs = con.Execute(strWhere, , 1)
Range("a1").CopyFromRecordset rs

rs.Close
con.Close
Set rs=Nothing
Set con=Nothing
End Sub

--
Gary''s Student - gsnu200796