Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Unable to UPDATE

Author  Topic 

scmay
Starting Member

22 Posts

Posted - 2007-02-02 : 00:09:45
Hi I am having errors updating a column in a database.

SQL statement in store procedure

>>SELECT @origUrno=OriginalUrno FROM ObTemp WHERE ConvertedUrno=@UrNo
>>UPDATE ObAdmission SET UrNo=@origUrno WHERE UrNo=@UrNo

Some of the data is incorrect while some are correct.

If I use this
>>UPDATE ObAdmission SET anotherColumnUrno=@origUrno WHERE UrNo=@UrNo

which is updating anotherColumnUrno rather than UrNo there are no errors.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-02 : 00:26:35
is ConvertedUrno the primary key ?

"which is updating anotherColumnUrno rather than UrNo there are no errors."
You mean there are error with your previous statement ?

try this

update u
set UrNo = OriginalUrno
from ObAdmission u inner join ObTemp t
on u.UrNo = t.ConvertedUrno
where u.UrNo = @UrNo




KH

Go to Top of Page
   

- Advertisement -