Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 VBS SQL text

Author  Topic 

bonaboard
Starting Member

7 Posts

Posted - 2010-04-28 : 17:23:01
I need to use VBS to export a sql statement to a text file.
Any ideas on how?
I have it exporting to the screen but haven't had any success going beyond that. (thanks go google)



Dim OdbcDSN
Dim connect, sql, resultSet

OdbcDSN = "DSN=untion;UID=runon;PWD=12345"
Set connect = CreateObject("ADODB.Connection")
connect.Open OdbcDSN

sql="SELECT FIRST_NAME, LAST_NAME FROM EMPLOYEE WHERE LAST_NAME = 'ROSS'"

Set resultSet = connect.Execute(sql)
On Error Resume Next
resultSet.MoveFirst
Do While Not resultSet.eof
WScript.Echo resultSet("LAST_NAME") & " , " & _
resultSet("FIRST_NAME")
resultSet.MoveNext
Loop

resultSet.Close
connect.Close
Set connect = Nothing

WScript.Quit(0)

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-28 : 17:27:49
Why does it need to be in VBS? Can't you instead use bcp.exe?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

bonaboard
Starting Member

7 Posts

Posted - 2010-04-29 : 09:38:20
It doesn't need to be VBS if something else works. It's the first time we've needed to do something like this so my experience is VERY limited. :)
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-04-29 : 10:51:13
This forum is supposed to be for scrips -- it's like a library. Maybe you should post in another forum or get a moderator to move the post.

Hey mods -- want to move this?


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -