| |
ehvbs
Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
|
I'm not sure, whether I understand you correctly, but ... To pass parameters to another process like osql.exe you may use WshShell.Run or WshShell.Exec specifying a suitable command string. Putting content of variables into the command string would lok like: sCmd = "osql -E -Q -q ""select name from sysdatabases where name = '" + sUsrInput + " ' """ Obviously, getting the quotes right will be a problem (my sample isn't tested!). I *think* your statement select name from sysdatabases where name = 'MYDB' if @@ROWCOUNT = 0 print 'DB DOES NOT EXISTENT' ELSE print 'DB EXISTS' will work if saved to xxx.sql and send to osql.exe with "osql -E -i xxx.sql". To create such .sql files from VBScript 'on the fly' you may use code like the sample proposed by Zifter for batch files http://www.visualbasicscript.com/tm.aspx?m=24422 The next problem is to get output/results from osql.exe. Using WshShell.Exec you can access the StdOut and Status property of the WshScriptExec object. For WshShell.Run you have to use the -o option of osql.exe. Either way - it will be a lot of complicated work. Do you really have so many / changing databases that you can't write some 5 or six scripts with hardcoded database names? If you need the flexibility / a lot of sql statements against different databases you should consider using ADO to access your server.
|
|