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.
| Author |
Topic |
|
Arun.G
Yak Posting Veteran
81 Posts |
Posted - 2010-06-09 : 07:07:10
|
| I want result like this:slno. date status months remarks1 06-05-2009 trainee 12 ok2 06-05-2010 confirm - in above table the 1st record is coming from one table, that was entered while the employee is joining in the organization.the 2nd record is coming from another table(stauschange) after some period the employee status is updated After i updated staus of the employee in statuschange table, the months should automatically update to 1strecord(12 month) and for 2nd record it should be nullif 3rd record is there means,the view should be like below:slno. date status months remarks1 06-05-2009 trainee 7 ok2 06-01-2010 probation 5 3 06-05-2010 confirmed -how can i write stored procedure for this in sqlserver 2008?pls help me as soon as possible, its urgent |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2010-06-09 : 08:28:33
|
| Could you perhaps copy the question from your textbook so that we have all the needed table structures, logic and sample data?http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
|
|
Arun.G
Yak Posting Veteran
81 Posts |
Posted - 2010-06-10 : 00:06:21
|
| I have these columns from one table(EmpInfo):effectivefrom statusid 2009-05-05 1effectivefrom is nothing but the joiningdate of the employee and the statusid is coming from Master Table:Statuswhich hasstatusid status1 trainee2 probation3 confirmationlike thati have another table Statuschange which has:status_id empid effectivefrom statuschageid months remarks1 1 2009-10-05 2 5 ok2 1 2010-05-05 3 7 gudlike that,here the Months colum should be updated automatically by finidnthe difference between latest statuschange to present changei.e in the status_id =1 row, the months 5 is the difference between the effectivefrom (empinfo table) and effectivefrom (statuschage table)and status_id=2 months 7 is the difference from status_id=1 record's effectivefrom ann status_id=2 record's effectivefrom columnsNow i wnat the result like below:slno effectivefrom statuschange months remarks action1 2009-05-05 trainee 5 view2 2009-10-05 probation 7 view3 2010-05-05 confirmed - edit viewthe first 2 records are only viewable, and the latest record(3) should only editable and viewablehow i can write the stored procedure for the above situtaion in sqlserver 2008?pls help |
 |
|
|
|
|
|