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)
 syntax help -loop through table

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2005-09-09 : 02:45:50
I'm trying to loop through my table and update a field based on looking up a value in another table.... I want to do something that loops through all the records in my table (dtstates$) looking up to table numbertype

I thought somethign like this but my syntax is wrong

update dtdates$ set dtdates$.numbertypeid=select numbertypeid from numbertype where numbertype.type= dtdate$.type

I want this to happen per record in dtdates$

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-09 : 02:51:31
Before trying this query, take a backup of those two tables
If the updation is wrong restore them

update T1 set T1.numbertypeid=T2.numbertypeid from dtdates$ T1 inner join numbertype T2
on T1.type= T2.type


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2005-09-09 : 06:42:11
thanks worked perfect
Go to Top of Page
   

- Advertisement -