Since I have converted the developers at work to the new dev database I created Im now working on copying objects from dev to live on each promotion. I know Red Gate has an excellent product for this (for $600), but Im trying to see if what I need can be done with stored procedures and user defined functions.
I have the stored procedure and user defined function to copy a stored procedure
Stored Procedure:
sql
CREATE PROCEDURE PromoteFromDev @ProcedureName VARCHAR(100)
AS
BEGIN
DECLARE @Proc VARCHAR(MAX)
IF @ProcedureName IS NOT NULL
SELECT @Proc = YourDatabase.dbo.udfGetProcedureScript(@ProcedureName)
IF @Proc IS NOT NULL
EXEC @Proc
END
User Defined Function
sql
CREATE FUNCTION dbo.udfGetProcedureScript(@ProcedureName VARCHAR(100))
RETURNS VARCHAR(MAX)
AS
BEGIN
DECLARE @Proc VARCHAR(MAX)
SELECT
@Proc = REPLACE((SELECT SysComments.Text AS "data()"
FROM
SysComments INNER JOIN Sysobjects
ON SysObjects.ID = SysComments.ID
WHERE
Sysobjects.name = @ProcedureName FOR XML PATH('')),'
','')
RETURN @Proc
END
Now what I need to come up with is a procedure that can compare, say the stored procedures on dev versus live so I have a list of procedures that need to be merged. Anyone got any ideas?