Wednesday, March 7, 2012

Get Stored Procedure

I know you can alter and create stored procedures, but is there a way to select a stored procedure? I rewrote some stored procedures for a database and now I want to go and update all the sites using that database(copies), but first I want to make sure that there were no other changes. So what I want to do is to write a page that will get the current stored procedure, compare it to what it should be, and if they are the same only them update it. Is this at all possible?[YODA MODE]
query on sysobjects and syscomments, and the answer to your question you shall find.
[/YODA MODE]|||This code returns a checksum value on each database object:select sysobjects.id,
sysobjects.name,
sysobjects.type,
sum(cast(checksum(syscomments.text) as bigint)) Object_Checksum
from sysobjects
inner join syscomments on sysobjects.id = syscomments.id
group by sysobjects.id,
sysobjects.name,
sysobjects.typeIf the checksum value of the old object does not match the checksum value of the new object, then the object definition has changed.

No comments:

Post a Comment