Doubt on using cursor
Hi,
I have an excel sheet which gives me the resource details(the number of resource assigned for a project). Using "Import and export data" wizard, i exported to sql server.
I have got two more tables, one is project table which has the project details and another is status table which has the weekly status regarding a project.
Example: Resource table:
Projid projname resource
------------------------------
1 abc 23
2 mno 45
Project table:
PId Projid Projname Prdetails.............
------------------------------
78 1 abc sample1
79 1 abc sample2
80 2 mno test1
status table:
Id PId date resource
---------------------------------
56 78 1/1/2007 23
57 79 1/1/2007 23
58 80 1/1/2007 45
My problem, resouce table has only projid and projname for which there are more than one entries in Project table(because projid, projname and prdetails form the composite primary key).
For the given projid and projname I have to get the PId from Project table and insert new records in status table with the PId and resource data given by resource table.
Since @@fetch_status is a global variable. I cannot use cursor for looping through the records generated by resource table and project table to insert a new record in status table.
Can any one help me how to solve this problem.
|