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 2005 Forums
 Transact-SQL (2005)
 Merging in sql server

Author  Topic 

konark
Yak Posting Veteran

60 Posts

Posted - 2009-06-02 : 19:43:38
STUDENT_DETAIL

StudentID MonthID SubjectType NoofUnitTests
1000 20090101 PHY 2
1001 20090101 PHY 1
1002 20090101 PHY 1
1003 20090101 PHY 3
1004 20090101 PHY 1
1005 20090101 PHY 2
1000 20090201 PHY 2
1001 20090201 PHY 1
1002 20090201 PHY 1
1003 20090201 PHY 3
1004 20090201 PHY 1
1005 20090201 PHY 2
1000 20090101 CHEM 2
1001 20090101 CHEM 0
1002 20090101 CHEM 1
1003 20090101 CHEM 1
1004 20090101 CHEM 1
1005 20090101 CHEM 2
1000 20090201 CHEM 3
1001 20090201 CHEM 1
1002 20090201 CHEM 0
1003 20090201 CHEM 3
1004 20090201 CHEM 1
1005 20090201 CHEM 2


LOOKUP
StudentID StudentRoll
1000 10
1001 11
1002 12
1003 13
1004 14
1005 15


OUTPUT

STUDENT_MASTER

StudentRoll MonthID Type Total
10 20090101 PHY 2
11 20090101 PHY 1
12 20090101 PHY 1
13 20090101 PHY 3
14 20090101 PHY 1
10 20090101 CHEM 2
11 20090101 CHEM 0
12 20090101 CHEM 1
13 20090101 CHEM 1
14 20090101 CHEM 1
10 20090201 PHY 2
11 20090201 PHY 1
12 20090201 PHY 1
13 20090201 PHY 3
14 20090201 PHY 1
15 20090201 PHY 2
10 20090201 CHEM 3
11 20090201 CHEM 1
12 20090201 CHEM 0
13 20090201 CHEM 3
14 20090201 CHEM 1
15 20090201 CHEM 2


I want to write a procedure which will load the STUDENT_MASTER from
STUDENT_DETAIL .I am a new bee , doing a college project. Please help me in doing it in the most efficient way.




Chandragupta Mourya

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-06-02 : 23:57:03
select StudentRoll,MonthID, SubjectType, NoofUnitTests
from LOOKUP l
inner join STUDENT_DETAIL sd on sd.StudentID = l.StudentID
Go to Top of Page

konark
Yak Posting Veteran

60 Posts

Posted - 2009-06-09 : 17:26:40
Thats not the rquirement. The data in STUDENT_DETAIL will always refresh last 2 months data and the proposed procedure will insert/update (merge) those 2 months data into STUDENT _MASTER?

Chandragupta Mourya
Go to Top of Page
   

- Advertisement -