I need to run a script 2 times, once for a local DB and once for a "server" DB, that will perform certain operations on both DB's, but only on the local DB for other opeartions. I would like to set a variable at the top then run script, reset it, then run script again, but my "if" statements are invalid syntax because the create SP statemtent is not playing well with the begin/end and the if statements:
declare @isCorpDB as bit
set @isCorpDB = 0
IF EXISTS(SELECT name FROM sysobjects WHERE name = 'QT_Checklist_GetApprovalQuestions' AND type = 'P')
DROP PROCEDURE QT_Checklist_GetApprovalQuestions
CREATE PROCEDURE [dbo].[QT_Checklist_GetApprovalQuestions] AS
Select * From QT_Sites_ApprovedVolumes_Questions
--- gives error - "Incorrect syntax near GO"