I have a script that uses variables to generate SQLe.g.--Declare counterdeclare @countr as intset @countr = 1declare @openMonth as intset @openMonth = 6declare @sqlBH as nvarchar (1000)set @sqlBH = ''declare @sqlBHFull as nvarchar (1000)set @sqlBHFull = ''WHILE @countr < 12 BEGIN -- BH_AllocEffortCost1 = acCost1,BH_AllocEffortCost2 = acCost2, ... etc... set @sqlBHFull = @sqlBHFull+'BH_AllocEffortCost'+cast(@countr as nvarchar)+'=acCost'+cast(@countr as nvarchar)+',' IF @countr >= @openMonth BEGIN set @sqlBH = @sqlBH+'BH_AllocEffortCost'+cast(@countr as nvarchar)+'=acCost'+cast(@countr as nvarchar)+',' END set @countr = @countr + 1 END--for December, minus the trailing commaset @sqlBH = @sqlBH+'BH_AllocEffortCost'+cast(@countr as nvarchar)+'=acCost'+cast(@countr as nvarchar)set @sqlBHFull = @sqlBHFull+'BH_AllocEffortCost'+cast(@countr as nvarchar)+'=acCost'+cast(@countr as nvarchar)
and the created values are used later in Update statementsUPDATE BudgetHeader SET @sqlBH
My question is, for debugging purposes how do I generate a final script where the variables have been evaluated and put into the correct place?I want to see a final script which instead of having UPDATE BudgetHeader SET @sqlBH
hasUPDATE BudgetHeader SET BH_AllocEffortCost1 = acCost1,BH_AllocEffortCost2 = acCost2, ...
Is there some software that will do this for me (preferably freeware) - all I have is MS SQL Server Utils (e.g. Enterprise Manager & Query Analyzer)?