Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

multipart identifier could not be bound Expand / Collapse
Author
Message
Posted Sunday, November 9, 2008 6:02 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, December 6, 2012 3:05 PM
Points: 13, Visits: 58
create table s(sid int, sno int)
create table t(sid int, sno int)

insert into s(sid,sno) values (1,1001)
insert into s(sid,sno) values (2,1002)
insert into s(sid,sno) values (3,1003)
insert into s(sid,sno) values (4,1004)

insert into t(sid,sno) values (1,1001)
insert into t(sid) values (2)
insert into t(sid) values (3)
insert into t(sid) values (4)

now am trying to update all the sno column in t

--Query
update t set t.sno=
(select s.sno from t,s where s.sid=t.sid and t.sno is null)
where t.sno is null and t.sid=s.sid

am getting the following error
--error
Msg 4104, Sevel 16, State 1, Line 1
The multi-part identifier on s.sid could not be bound

Please help me where i shall need to correct the query above.

--Thank You
Chaitanya
Post #599542
Posted Sunday, November 9, 2008 11:47 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, November 6, 2014 1:00 PM
Points: 5,333, Visits: 25,277
First this clause of your statement:
select s.sno from t,s where s.sid=t.sid and t.sno is null

will return more than a single value, this then yieds the error

Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, = or when the subquery is used as an expression.
The statement has been terminated.


If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Post #599580
Posted Sunday, November 9, 2008 12:22 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:28 AM
Points: 40,609, Visits: 37,068

UPDATE t SET t.sno = s.sno
FROM t INNER JOIN s ON s.sid=t.sid
WHERE t.sno IS NULL



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #599585
Posted Sunday, November 9, 2008 7:47 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, December 6, 2012 3:05 PM
Points: 13, Visits: 58
Thank you for the solution sir.

But can you please tell me why the where clause is bouncing and what is the reason?
Post #599625
Posted Monday, November 10, 2008 1:08 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:28 AM
Points: 40,609, Visits: 37,068
vempralachaitanya (11/9/2008)
But can you please tell me why the where clause is bouncing and what is the reason?


Bouncing?



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #599670
Posted Monday, November 10, 2008 6:50 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, December 11, 2014 3:10 AM
Points: 1,274, Visits: 1,987
vempralachaitanya (11/9/2008)
--Query
update t set t.sno=
(select s.sno from t,s where s.sid=t.sid and t.sno is null)
where t.sno is null and t.sid=s.sid

am getting the following error
--error
Msg 4104, Sevel 16, State 1, Line 1
The multi-part identifier on s.sid could not be bound

The highlighted element (s.sid) does not refer to any object used outside the subquery, hence the error. You cannot refer into a subquery, but references the other way work fine, so the following achieves what you want.
update t
set t.sno=(select s.sno from s where s.sid=t.sid)
where t.sno is null



Derek
Post #599832
Posted Monday, November 26, 2012 9:49 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 26, 2012 9:46 PM
Points: 1, Visits: 0
Hi all, i m new to sql... i m facing a problem while executing this query on sql server 2005...
the multipart identifier could not be bound..

SELECT DISTINCT '(' + tblDefProducts.Product_number + ') ' + tblDefProducts.item_name AS Product_number, tblDefProducts.product_id
FROM tblDefProducts
Where 1 = 1
AND tblDefProducts.Gender In (1)

I have a table named tbllineitems having column line_item_id...i want to put a check on it that only the item against selected lineitem should be shown...plzzz help me...thanx in advance..
Post #1388932
Posted Monday, November 26, 2012 11:55 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:28 AM
Points: 40,609, Visits: 37,068
Please post new questions in a new thread. Thank you.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1388975
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse