This is a question about some stored procedures running on MSSQL 8 (I think that’s SQL Server 2000).
I have two stored procedures left by my predecessor at the company.
The “Modify” window for the first procedure looks something like this:
ALTER PROCEDURE [dbo].[Proc1]
@ID,
@someBool
AS
BEGIN
SELECT colA, colB, colC
FROM myTable
WHERE colA = @ID AND colB = @someBool
END
The second procedure is very similar, being something along the lines of:
ALTER PROCEDURE [dbo].[Proc2]
@ID
AS
BEGIN
SELECT colA, colB
FROM myTable
WHERE colA = @ID AND colB = FALSE
END
Obviously, the real procedures are more complicated than this and require a lot more maintenance when changes are made.
Rather than maintaining these two queries separately, which pretty much sucks, I was wondering if there was any way to simply have Proc2 do something along the lines of:
ALTER PROCEDURE [dbo].[Proc2]
@ID
AS
BEGIN
EXEC Proc1(@ID, FALSE)
"drop colC"
"return modified result"
END
Any ideas on the best way to go about this?
Maybe something like this?