Maybe, something like this?

SELECT A.AffiliateID, dbo.B.RateCodeID
Into #TempTable
FROM   dbo.tbl_affiliates A 
INNER JOIN dbo.tbl_affiliates_ratecodes B ON A.AffiliateID =
B.AffiliateID
WHERE (A.ReferringDomain = '@referringdomain')  AND (B.RateCode =
'@ratecode')

SET @verify = @@rowcount

/* insert an entry into the referrer log if the domain has been
verified. */
IF @verify > 0
        BEGIN
                INSERT INTO dbo.tbl_affiliates_log (AffiliateID,
RateCodeID)
                Select AffiliateID, RateCodeID
                From #TempTable
        END
END

/* The following will "return the recordset" from the stored procedure.
If that's not necessary, then take out the following line */
Select * from #TempTable 




-----Original Message-----
From: Bosky, Dave [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 02, 2003 09:15
To: SQL
Subject: Stored procedure help?

How can I use values returned from one query in another query?
What I want to do is insert values returned from one query into another
table.
I'm still learning how to write T-SQL SP using MS SQL Server 2000.

SELECT A.AffiliateID, dbo.B.RateCodeID
FROM   dbo.tbl_affiliates A 
INNER JOIN dbo.tbl_affiliates_ratecodes B ON A.AffiliateID =
B.AffiliateID
WHERE (A.ReferringDomain = '@referringdomain')  AND (B.RateCode =
'@ratecode')

SET @verify = @@rowcount

/* insert an entry into the referrer log if the domain has been
verified. */
IF @verify > 0
        BEGIN
                INSERT INTO dbo.tbl_affiliates_log (AffiliateID,
RateCodeID)

                VALUES (@??????,@??????)
        END
END


Thanks,
Dave Bosky




HTC Disclaimer:  The information contained in this message may be
privileged and confidential and protected from disclosure. If the reader
of this message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, you
are hereby notified that any dissemination, distribution or copying of
this communication is strictly prohibited.  If you have received this
communication in error, please notify us immediately by replying to the
message and deleting it from your computer.  Thank you.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=6
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=6

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

                        

Reply via email to