Hi, I'm having an issue with my SQL Statement. I'm trying to declare a variable and set it to the count of the number of records that exist for a particular order number. The problem is when I execute the statement I get this error:
Msg 4104, Level 16, State 1, Line 3
The multi-part identifier "prod.dbo.HEADERS.ORDER_NUMBER" could not be bound.
I'm 100% Sure everything is spelled correctly and capitalized properly. This is the code I'm trying to run:
DECLARE @test INT
SET @test = (SELECT COUNT(*) FROM [prod].[dbo].[LINES] WHERE [ORDER_NUMBER] = [prod].[dbo].[HEADERS].[ORDER_NUMBER])
Any idea what might be causing this? Thank you.
- It's a long way to the top if you want to rock n' roll - AC/DC