#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 140
Default SQL syntax

I will be very grateful for the SQL syntax to use for an ADO query on a large
csv to pull in all the rows of data for one specific fund to an Excel
spreadsheet. There are about 35 funds listed in the first column headed
"Funds".

I can get all the data across but i would like to just import the data for
one fund say fund "XYZ" in the "Funds" field.
--
with kind regards

Spike
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 694
Default SQL syntax

I ran the macro recorder on 2007 and got the following sql for a three column
table in a csv file amend as required.:


"SELECT test1.FUNDS, test1.NO, test1.YN" & Chr(13) & "" & Chr(10) &
"FROM test1.csv test1" & Chr(13) & "" & Chr(10) & "WHERE (test1.FUNDS='XYZ')"
_
)


Sub Macro2()
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _

"ODBC;DBQ=C:\USERS\ADMIN\DESKTOP;DefaultDir=C:\USE RS\ADMIN\DESKTOP;Driver={Microsoft Text Driver (*.txt; *.csv)};DriverId=27;FIL=text" _
), Array( _

";MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;S afeTransactions=0;Threads=3;UserCommitSync=Yes;" _
)), Destination:=Range("$A$1")).QueryTable
.CommandText = Array( _
"SELECT test1.FUNDS, test1.NO, test1.YN" & Chr(13) & "" & Chr(10) &
"FROM test1.csv test1" & Chr(13) & "" & Chr(10) & "WHERE (test1.FUNDS='XYZ')"
_
)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_from_textfile"
.Refresh BackgroundQuery:=False
End With
End Sub

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Spike" wrote:

I will be very grateful for the SQL syntax to use for an ADO query on a large
csv to pull in all the rows of data for one specific fund to an Excel
spreadsheet. There are about 35 funds listed in the first column headed
"Funds".

I can get all the data across but i would like to just import the data for
one fund say fund "XYZ" in the "Funds" field.
--
with kind regards

Spike

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default SQL syntax

Use a where clause of column_name = "XYZ", or maybe filter the recordset
when retrieved.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Spike" wrote in message
...
I will be very grateful for the SQL syntax to use for an ADO query on a
large
csv to pull in all the rows of data for one specific fund to an Excel
spreadsheet. There are about 35 funds listed in the first column headed
"Funds".

I can get all the data across but i would like to just import the data for
one fund say fund "XYZ" in the "Funds" field.
--
with kind regards

Spike



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
general syntax AskExcel Excel Worksheet Functions 0 February 4th 06 07:01 PM
syntax question Giselle Excel Worksheet Functions 4 January 29th 06 01:59 AM
VBA syntax Sunantoro Excel Discussion (Misc queries) 1 September 21st 05 03:19 AM
If then syntax RL Excel Worksheet Functions 3 June 22nd 05 05:30 AM
Syntax Help Dmorri254 Excel Worksheet Functions 2 March 2nd 05 02:51 PM


All times are GMT +1. The time now is 06:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"