Link to home
Start Free TrialLog in
Avatar of mnoisette
mnoisetteFlag for United States of America

asked on

Declaring and Setting SQL Variables

I am trying to write a SQL statement that uses a very simple variable.
I keep getting an error that says:
"The multipart identifier could not de bound"

Here is an example of my statement:

USE TSQL2012
GO
DECLARE @Total Int;
SET @Total = (Sales.OrderDetail.unitprice * Sales.OrderDetail.qty)
SELECT @Total AS 'Total Price'
FROM Sales.OrderDetail

What am I missing
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial