SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


multipart identifier could not be bound


multipart identifier could not be bound

Author
Message
vempralachaitanya
vempralachaitanya
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 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
bitbucket-25253
bitbucket-25253
SSCertifiable
SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)

Group: General Forum Members
Points: 7821 Visits: 25280
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
GilaMonster
GilaMonster
SSC Guru
SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)

Group: General Forum Members
Points: 87265 Visits: 45272
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, MVP, M.Sc (Comp Sci)
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


vempralachaitanya
vempralachaitanya
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 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?
GilaMonster
GilaMonster
SSC Guru
SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)

Group: General Forum Members
Points: 87265 Visits: 45272
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, MVP, M.Sc (Comp Sci)
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


StarNamer
StarNamer
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1642 Visits: 1992
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
waqasanwar98
waqasanwar98
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 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..
GilaMonster
GilaMonster
SSC Guru
SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)

Group: General Forum Members
Points: 87265 Visits: 45272
Please post new questions in a new thread. Thank you.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search