need help with an UPDATE statement

M

Milsnips

i'm sure i should know how to do this, but its been a while with SQL:

i have 2 tables..
1. Pricing
2. Request

Pricing has about 10 records with pricingID being primary.
Request has a field called Price which needs to populate the Request "price"
table with the price values from Pricing..

both tables have pricingID in them as lookup field.

hope u understand clearly enough.
thanks,
Paul
 
K

Karl Seguin

Not too clear, do you mean something like:

UPDATE Request
SET Price = dbo.GetPrice(priceId)


with the udf being:
CREATE FUNCTION dbo.GetPrice
(
@priceId INT
)RETURNS MONEY
AS
BEGIN
RETURN
(
SELECT Price
FROM Price
WHERE PriceId = @priceId
)
END

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top