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
 Transact-SQL (2000)
 update column

Author  Topic 

hai
Yak Posting Veteran

84 Posts

Posted - 2007-09-06 : 10:48:39
I'm trying to update the column (ckid) to increment by 1 with the following statement below, but it is not working. It update the field with the same value...can someone point out where I did wrong?

Thank-you....

update T set T.ckid=X.ckID
from tbl1 T
inner join (
select (MAX(isnull(ckID,100))+1) as ckID,numid,comp,ln1,nl2
from tbl1
group by umid,comp,ln1,nl2
)X
on T.numID=X.numID
and T.comp=X.comp
and T.ln1=X.ln1
and T.Ln2=X.Ln2

Kristen
Test

22859 Posts

Posted - 2007-09-06 : 11:03:25
I presume

group by numid,comp,ln1,nl2

is a typo?

therefore is this the actual code you are using? (I figured you would have cut&pasted it, but obviously you didn't ...)

Kristen
Go to Top of Page

hai
Yak Posting Veteran

84 Posts

Posted - 2007-09-06 : 11:08:40
Hi Kristen,
Yes...it is a typo on my part.

thanks
Go to Top of Page
   

- Advertisement -