Variables in Stored Procedures...

Soldato
Joined
18 Oct 2002
Posts
16,033
Location
The land of milk & beans
Admittedly my SQL is a bit rusty when deviating from the basics, but this shouldn't be as difficult as it's turning out to be.

Anyway, put simply the problem is i need to run a query, and return the values into declared variables, the below is just returning null for both entries :(

Any help appreciated!

DECLARE @AccountID int
DECLARE @BroadcastID int
DECLARE @CampaignID int
SET @BroadcastID = 1

SELECT AccountID, CampaignID FROM Broadcasts WHERE BroadcastID = @BroadcastID
SELECT @AccountID AS AccountID
SELECT @CampaignID AS CampaignID
 
Dammit, the OcUK effect strikes again - post something after trying for a couple of hours, then solve it 10 minutes later :)

Here's what i needed to do if anyone ever runs into the same problem...

DECLARE @AccountID int
DECLARE @BroadcastID int
DECLARE @CampaignID int
SET @BroadcastID = 1

SELECT @AccountID = AccountID, @CampaignID = CampaignID FROM Broadcasts WHERE BroadcastID = @BroadcastID
SELECT @AccountID, @CampaignID
 
Back
Top Bottom