Whats wrong with my SQL code? HELP Please!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ITHELP85
    New Member
    • Nov 2008
    • 8

    Whats wrong with my SQL code? HELP Please!!!

    Hello
    I am trying to get a table attribute to calculate the result of 2 attribute in another table. I am using SQL Server 2005. I got another table to do this and it works fine, but the only difference is is that the attributes are in the same table. My code is posted below but it does not Work. I get the message:

    -------------------------------------------------------------------------
    The multi-part identifier "ITEM_PURCHASE. LocalCurrencyAm t" could not be bound.
    Msg 4104, Level 16, State 1, Line 1
    The multi-part identifier "ITEM_PURCHASE. ExchangeRate" could not be bound.
    Msg 4104, Level 16, State 1, Line 1
    The multi-part identifier "ITEM_PURCHASE. LocalCurrencyAm t" could not be bound.
    Msg 4104, Level 16, State 1, Line 1
    The multi-part identifier "ITEM_PURCHASE. ExchangeRate" could not be bound.
    ------------------------------------------------------------------------

    CREATE TABLE WAREHOUSE(
    ItemNumberSK int NOT NULL,
    ItemName char(50) NOT NULL,
    ItemUnitPrice as CASE
    WHEN ITEM_PURCHASE.L ocalCurrencyAmt > 0 AND ITEM_PURCHASE.E xchangeRate > 0 Then ITEM_PURCHASE.L ocalCurrencyAmt * ITEM_PURCHASE.E xchangeRate * 1.2
    END,
    ItemQty numeric(7, 0) NOT NULL,
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    I'm not sure if creating a check constraint like that is possible. Even if it's possible, I think it would be better if you use trigger to handle this.

    -- CK

    Comment

    Working...