Help with Query
- From: Ron <ewentms@xxxxxxxxx>
- Date: Sat, 25 Jun 2005 00:07:01 -0700
I am working with 3 tables:
BJChoice - Prod# and Prices where Bj's Price is less than TO Prices
TOChoice - Prod# and Prices where TO's Price is less than BJ Prices
A Prod# in one table does not appear in the other table
Prices - Prod# and Minimum Price between BJ and TO
What I want to do is write a Stored Procedure which will put the Bj.Price in
Prices.MinimumPrice for the Prod# it corresponds to and put the TO.Price in
Prices.MinimumPrice for the Prod# it corresponds to. I wrote one SQL
Statement which is:
UPDATE dbo.tblPrices
SET Minimum = BJ
FROM dbo.tblPrices INNER JOIN
dbo.tblBJChoice ON dbo.tblPrices.Prod# =
dbo.tblBJChoice.Prod#
WHERE (dbo.tblPrices.Prod# = dbo.tblBJChoice.Prod#)
When I ran it, it changed it to:
ALTER PROCEDURE dbo.updBJMinimum
AS UPDATE dbo.tblPrices
SET Minimum = BJ
FROM dbo.tblPrices INNER JOIN
dbo.tblBJChoice ON dbo.tblPrices.Prod# =
dbo.tblBJChoice.Prod#
WHERE (dbo.tblPrices.Prod# = dbo.tblBJChoice.Prod#)
AND It DELETED tblPrices !!
Any ideas or any where else I can go for help or another way to approach
this problem
TIA
--
Ron
.
- Prev by Date: Return Part of a text field
- Next by Date: Re: Insert non duplicate data
- Previous by thread: Return Part of a text field
- Next by thread: select most common value
- Index(es):