![]() | ![]() | ![]() |
This article has been published [fromdate] |
In this post we will see if we can run a VB Script from SQL Server. Yes, SQL Server allows to run external [gs script]s. So, here is the process how to run a VB Script from TSQL Code.
Well to test this lets first create a sample VB Script which will just display a message.
Dim VarSetMessage VarSetMessage = "Running VB Script from SQL Server..." 'Display message WScript.Echo VarSetMessage
Save it as “myMsg.vbs” on “C:\” drive of your machine. Okey, before running this script from SQL Server, lets see how to run it from Command Prompt. To do this:
Start => Run => cmd => ENTER Type Cscript C:\myMsg.vbs => ENTER
Now to run the VB Script from SQL Server just run the same command line we tested above using xp_cmdshell from SQL Server.
EXEC XP_CMDSHELL 'CScript C:\myMsg.vbs'
and we are done !!!
Note: You may need to configure xp_cmdshell if not configured before.
SOURCE | LINK (SQLjourney.com) | LANGUAGE | ENGLISH |