none
Msg 4104 Level 16 The multi-part identifier X could not be bound.

    Question

  • this is so stupid and simple and I am annoyed over having to spend so much on this silly simple stuff.

    I am sure I am just making a silly mistake.

    I am trying to remove records from one table.  The table holds 19000 something records.
    To determine WHICh records to delete, I have another table that contains the 45 I want to delete.

    So I wrote this very simple query
    Delete from tbl_X
    where tbl_X.FieldA = tbl_Y.FieldA;

     

    The message I get is:

    Msg 4104, Level 16, State 1, Line 1
    The multi-part identifier "tblY.FieldA" could not be bound.


    Please tell me I am stupid!

    Thanks!

    Friday, September 07, 2007 5:48 PM

Answers

  • tbl_Y needs to be mentioned as a table in a FROM clause or a JOIN clause. Perhaps you want something like

     

    DELETE FROM tbl_X

    WHERE tbl_X.FieldA IN (SELECT FieldA FROM tbl_Y)

     

    HTH,

     

    Don

    Friday, September 07, 2007 6:23 PM
  • I've always coded a delete like this as a join:

     

    DELETE tbl_X

    FROM tbl_X INNER JOIN tbl_Y

    ON tbl_X.FieldA = tbl_Y.FieldA

     

     

    Friday, September 07, 2007 6:52 PM

All replies

  • tbl_Y needs to be mentioned as a table in a FROM clause or a JOIN clause. Perhaps you want something like

     

    DELETE FROM tbl_X

    WHERE tbl_X.FieldA IN (SELECT FieldA FROM tbl_Y)

     

    HTH,

     

    Don

    Friday, September 07, 2007 6:23 PM
  • I've always coded a delete like this as a join:

     

    DELETE tbl_X

    FROM tbl_X INNER JOIN tbl_Y

    ON tbl_X.FieldA = tbl_Y.FieldA

     

     

    Friday, September 07, 2007 6:52 PM
  • THANKS!

     

    And thanks for the quick reply!

     

    Richard

     

    Friday, September 07, 2007 7:31 PM
  • THANKS!

     

    And thanks for the quick reply!

     

    Richard

     

    Friday, September 07, 2007 7:32 PM
  • I'm sorry but I have to create a cluster with SQL 2005 Standard
    have the manuals that you used to create it ?
    Monday, March 01, 2010 8:09 AM
  • The tbl_y must be mencioned in a join clause. I aways use the IN clause to supply the join. it work's!
    Try this:
     

    DELETE FROM tbl_X

    WHERE tbl_X.FieldA IN (SELECT FieldA FROM tbl_Y)

    Monday, March 01, 2010 11:18 AM