SQL2CSV VBScript

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

SQL2CSV VBScript

Post by mightycpa » Sat Mar 28, 2015 2:44 am

Hi,

I was tooling around in the forums, and I stumbled upon this post: viewtopic.php?t=6166#p28558

The post describes a VBScript that loads SQL results to a CSV. I tried it out, and my results were really fast, as follows:

~4,000 records - 4 seconds :)
~ 270,000 records - 40 seconds :D
~3,100,000 records - well, it choked on the first record. :(

I'm using SQL Server with a SELECT * FROM blah-blah-blah. It turns out that the table I was going to copy has a column in it of the data type "timestamp". It turns out that this is not a timestamp at all, but rather, a poorly named binary field that used to support versioning. From everything I could find, VBScript doesn't play well with binary. I wonder if you know any tricks that could improve the script to convert the data when it encounters it. I doubt it is very common, and in fact, I'm going to retype those columns to actual DATETIME formats. Still, I thought I'd ask.

For now, I have modified this SELECT script to name each column, and to convert the binary column to an integer. My results were thus:

~3,100,000 records - 29 minutes, created a file 645,136KB. So, about 22000 KB per minute. Not bad at all. :lol:

Also, during each of my scripts, I saw this. Is there any way to turn that off? I tried IGNOREERRORS, and VBScript
On Error Resume Next, On Error GoTo 0 but neither worked. It's not really harmful or disruptive, but again, I thought I'd ask.

Image
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: SQL2CSV VBScript

Post by mightycpa » Sun Mar 29, 2015 6:25 am

Let>VBSTIMEOUT=-1

You've thought of almost everything, haven't you?
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts