www.webdeveloper.com
Results 1 to 5 of 5

Thread: multi-part identifier could not be bound

  1. #1
    Join Date
    Jun 2010
    Posts
    47

    multi-part identifier could not be bound

    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:


    Code:
    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.

  2. #2
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    The query doesn't make any sense. Think about it: What is [prod].[dbo].[HEADERS].[ORDER_NUMBER]?
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  3. #3
    Join Date
    Jun 2010
    Posts
    47
    Quote Originally Posted by svidgen View Post
    The query doesn't make any sense. Think about it: What is [prod].[dbo].[HEADERS].[ORDER_NUMBER]?
    I'm not a database guy, and I'm sure I'm definitely missing something, but what I intended it to be is the [database].[schema].[Table].[Column]

  4. #4
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    Hehe ... OK.

    So, [prod].[dbo].[HEADERS].[ORDER_NUMBER] doesn't refer to an ORDER_NUMBER from any particular row. You need to specify a row, or you need to be performing a JOIN.
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  5. #5
    Join Date
    Feb 2012
    Location
    youTUBE
    Posts
    234
    try
    Code:
     
    ... COUNT(ORDER_NUMBER) ...
    (with nothing to catch it!)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles