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 in stored procedures

Author  Topic 

sahu74
Posting Yak Master

100 Posts

Posted - 2002-10-19 : 13:19:59
I have a table(XYZ) with a composite primary key (say PK1 and PK2). I need to update table (ABC) (whose composite primary keys are PK1, PK2 and yearNo) in the following manner.

update ABC
set NumStudent = var1
where yearNo = var2
and PK1 = var3
and PK2 = var4

I want to update table ABC in the form of a loop for every combination of yearNo, var3, var4.

Also the value of var1 is the result of a query that changes with the value of var3 and var4 (i.e the value of PK1 and PK2).

Any help will be greatly appreciated.

pks.

   

- Advertisement -