Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stored Procedure Code
Message
General information
Forum:
Visual Basic
Category:
SQL Server
Miscellaneous
Thread ID:
00757024
Message ID:
00757184
Views:
17
Exactly what I needed. Concise and to the point! 10 Points from me. With this (plus an if exists ... drop proc/trigger)I have the ability to give myself an on-site utility to modify the procs and triggers from the client machine. This little tool will save me hours of getting grudging admin cooperation!!

Thanks,
Joe.

>>How can I display the actual code from a stored procedure in VB?
>>
>>My Thanks in advance,
>-----------------------------------
>
>Public Function GetSProcCode(strProcedureName As String)
>Dim cn As Object
>Dim rs As Object
>Dim strSelect As String
>
>strSelect = "select C.text from sysobjects O, syscomments C Where O.type = 'P' and C.id = O.id and text like "
>strSelect = strSelect & "'%" & Trim(strProcedureName) & "%'"
>
>Set cn = CreateObject("ADODB.Connection")
>-- open database with appropriate connection string
>cn.Open "provider=sqloledb;data source=<YourDataSource>;initial catalog=<YourDataBase>", "<your login name>", "<your passsword>"
>
>Set rs = cn.execute(strSelect)
>GetSProcCode = rs.fields("text").Value
>
>End Function
>
>
>' and then...
>Debug.Print GetSProcCode("up_MyProcedure")
>
>
>You could also wrap this into a stored procedure in the database to lessen overhead... but to be honest, the "LIKE" makes this such a slow query, relatively speaking, that the on-the-fly compile plan isn't going to be a high percentage of the time the process will take.
>
>Note that this won't work if the sproc was compiled using "with encryption," which has been cracked anyway so isn't of too much use...
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Previous
Next
Reply
Map
View

Click here to load this message in the networking platform