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-10 : 03:46:09
|
| i got results from stroed prcedure like below:slno effectivefrom status months1 2009-10-05 trainee 72 2010-05-05 confirmed -in front end the latest record(slno 2) only can be editablethe above one should be statichow to achieve this thrugh stored procedure in sqlserver 2008using rowcount(max) or anytother methods? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-10 : 04:00:32
|
Sorry but you are not clear.What do you want the stored procedure to do or what is your problem? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Arun.G
Yak Posting Veteran
81 Posts |
Posted - 2010-06-10 : 04:08:51
|
| 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.ein 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 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-06-10 : 05:19:51
|
You can use a trigger to do this. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|
|