Home > Archive > MS SQL Server MSEQ > June 2005 > Help with Query









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Help with Query
Ron

2005-06-25, 3:23 am

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
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com