What is the problem with the logic in my UPDATE statement?

Posted by Stefan Åstrand on Stack Overflow See other posts from Stack Overflow or by Stefan Åstrand
Published on 2010-04-10T16:12:33Z Indexed on 2010/04/10 16:23 UTC
Read the original article Hit count: 325

Filed under:
|
|

Hello,

I would appreciate some help with an UPDATE statement.

I want to update tblOrderHead with the content from tblCustomer where the intDocumentNo corresponds to the parameter @intDocumentNo. But when I run the my statement, the order table is only updated with the content from the first row of the customer table.

What is the problem with my logic?

I use Microsoft SQL Server.

Thanks,

Stefan

UPDATE      dbo.tblOrderHead
SET         dbo.tblOrderHead.intCustomerNo   = @intCustomerNo ,
            dbo.tblOrderHead.intPaymentCode  = dbo.tblCustomer.intPaymentCode,
            dbo.tblOrderHead.txtDeliveryCode = dbo.tblCustomer.txtDeliveryCode,
            dbo.tblOrderHead.txtRegionCode   = dbo.tblCustomer.txtRegionCode,
            dbo.tblOrderHead.txtCurrencyCode = dbo.tblCustomer.txtCurrencyCode,
            dbo.tblOrderHead.txtLanguageCode = dbo.tblCustomer.txtLanguageCode
FROM        dbo.tblOrderHead
INNER JOIN  dbo.tblCustomer ON dbo.tblOrderHead.intOrderNo = @intDocumentNo

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about inner-join