We help IT Professionals succeed at work.
Get Started

VB Script: use sqlcmd in VBscript

Luis Diaz
Luis Diaz asked
on
1,603 Views
Last Modified: 2015-04-14
Hello experts,

I have the following sqlcmd code:

@echo off

sqlcmd -S server -d db -U user -P password -i "file1.sql" -o "TEST.csv" -s";" -w 700 -W

findstr /B /V /C:"-------------------;-----------;-------;-------" TEST.csv > test_match_combined.csv

del TEST.csv
Pause

Open in new window


I would like to introduce this code into VBscript with the following requirements:
The following commands need to be defined at the beginning of the code as variables:
sqlcmdrun, "-S", "-d", "-U", "P", "-i", "-o"
If DB is not accessible log ouput: "Error, Unable to connect to the db, please check db variables".

Thank you for your help.
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 16 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE