Friday, March 23, 2012

Export code procedure

I'd like to export code the procedure and alter the code and import
again in to the database, but this in the commandline.
Thanks,
Carlos DokiHello Carlos,
The following script gives you the text of a given stored procedure.
MyScript.vb
--
dim cn
dim StoredProcedureLines
set cn=CreateObject("ADODB.Connection")
cn.open "Provider=SQLOLEDB;Data Source=.\SQLEXPRESS;Initial
Catalog=TEST;Integrated Security=SSPI"
set StoredProcedureLines=cn.execute("sp_helptext 'MyStoredProcedure'")
while not StoredProcedureLines.eof
WScript.Echo(StoredProcedureLines(0))
StoredProcedureLines.MoveNext
wend
You just need to alter the text and execute the new DROP PROCEDURE / CREATE
PROCEDURE statement. You can save this script as MyScript.vb and execute it
from the command line:
C:\>CSCRIPT MyScript.vb
I hope it helps you...
Best regards.
Elyo Ravuna
"carlosdoki@.gmail.com" wrote:

> I'd like to export code the procedure and alter the code and import
> again in to the database, but this in the commandline.
>
> Thanks,
>
> Carlos Doki
>

No comments:

Post a Comment