I think I am trying to do something that is relatively straight forward, but keep getting the 'Must Declare Scalar Variable Error'. I have two variables:
DECLARE @CountOfThisCampaignSegment int
DECLARE @CountOfLastCampaignSegment int
select @CountOfThisCampaignSegment = COUNT(seg1) from #thisCampaignFinal
select @CountOfLastCampaignSegment = COUNT(seg1) from #lastCampaignFinal
I read that somewhere else that it seems I need to turn them into nvarchar, but I need to compare these two variables for an IF statement down the track in my procedure - so I am not sure if that would cause problems?
If anyone could give me some advice and background on why SQL Server throws this error, it would be greatly appreciated!
Many Thanks!