By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,419 Members | 1,648 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,419 IT Pros & Developers. It's quick & easy.

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

P: 8
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.LocalCurrencyAmt" 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.LocalCurrencyAmt" 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.LocalCurrencyAmt > 0 AND ITEM_PURCHASE.ExchangeRate > 0 Then ITEM_PURCHASE.LocalCurrencyAmt * ITEM_PURCHASE.ExchangeRate * 1.2
END,
ItemQty numeric(7, 0) NOT NULL,
Nov 9 '08 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
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
Nov 11 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.