VBNewbie07
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 5/2/2007
-
Status: offline
|
How to export a SQL View to CSV using VBScript
-
Wednesday, May 02, 2007 7:50 AM
( #1 )
Hi all. I would like to know if there is way to export a SQL View to a csv file using VBScript? Thank you in advance!
|
|
|
dm_4ever
-
Total Posts
:
3498
- Scores: 67
-
Reward points
:
0
- Joined: 6/29/2006
- Location: Orange County, California
-
Status: offline
|
RE: How to export a SQL View to CSV using VBScript
-
Wednesday, May 02, 2007 1:19 PM
( #2 )
Not certain, but you can export to a csv from an Access DB like this...
Option Explicit
Dim strDBPath : strDBPath = "c:\temp\test.mdb"
Dim strCSVDirPath : strCSVDirPath = "c:\temp\"
Dim strCSVFileName : strCSVFileName = "CSVExport.csv"
Dim strTableName : strTableName = "SomeTable"
Dim objConnection : Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider = Microsoft.Jet.OLEDB.4.0; " & _
"Data Source = " & strDBPath
Dim commandstring : commandstring = "SELECT * INTO [text;HDR=Yes;Database=" & _
strCSVDirPath & "]." & strCSVFileName & _
" FROM " & strTableName
objConnection.Execute commandstring
You might be able to modify this to export from an SQL server...not sure though... You might also just query the Table using ADO and use the GetString method to format the data and write it out to a .csv file.
|
|
|
VBNewbie07
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 5/2/2007
-
Status: offline
|
RE: How to export a SQL View to CSV using VBScript
-
Thursday, May 03, 2007 12:58 AM
( #3 )
Thanks dm_4ever! I'll give it a try.
|
|
|
peachtea
-
Total Posts
:
41
- Scores: 0
-
Reward points
:
0
- Joined: 7/5/2007
- Location: Singapore
-
Status: offline
|
RE: How to export a SQL View to CSV using VBScript
-
Tuesday, July 17, 2007 3:03 PM
( #4 )
hi there... just a qn to hijack this thread is it possible for vb script to pick up certain information from 2 separate access tables and insert them into the 3rd table before export it out to a csv file? All 3 tables r in the same db Thanks in advance :)
|
|
|
dm_4ever
-
Total Posts
:
3498
- Scores: 67
-
Reward points
:
0
- Joined: 6/29/2006
- Location: Orange County, California
-
Status: offline
|
RE: How to export a SQL View to CSV using VBScript
-
Tuesday, July 17, 2007 3:30 PM
( #5 )
I don't see why it wouldn't be possible with the right SQL query.
|
|
|