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 |
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-05-28 : 00:33:53
|
| I am using this but it's locking up clocing_status table. What is wrong? or what can I include or modify to preven this happening? Again thanks for looking into this and help.begin transaction;if exists(select cs.emp_id from clocking_status cswhere not exists(select cd.emp_idfrom dbo.CLOCKING_DETAILS cdwhere cs.emp_id=cd.emp_id))begininsert into clocking_status(emp_id,clocking_date,clocking_status)select e.emp_id,'','' from employees ewhere (e.active='1') and (not exists (select cs.emp_id from clocking_status cs where e.emp_id=cs.emp_id))endbeginupdate clocking_statusset clocking_status= (SELECT min(CASE WHEN (cd.time_out IS NULL) THEN 'in' ELSE 'out' END) AS cStatusFROM dbo.CLOCKING_DETAILS AS cdwhere (cd.emp_id=clocking_status.emp_id)GROUP BY cd.emp_id),clocking_date = (SELECT max(cd.clocking_date) FROM dbo.CLOCKING_DETAILS AS cdwhere (cd.emp_id=clocking_status.emp_id)GROUP BY cd.emp_id)ENDSELECT TOP (100) PERCENT e.emp_id, e.first_name AS [First Name], e.last_name AS [Last Name], dbo.CLOCKING_STATUS.clocking_statusFROM dbo.EMPLOYEES AS e INNER JOIN dbo.CLOCKING_STATUS ON e.emp_id = dbo.CLOCKING_STATUS.emp_idWHERE (e.active = '1')ORDER BY e.emp_id |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-05-28 : 07:47:28
|
There is no COMMIT / ROLLBACKWebfred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-05-28 : 07:50:21
|
Great spot! E 12°55'05.63"N 56°04'39.26" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-05-28 : 08:52:49
|
| If you want to find out other open transactions, rundbcc opentranMadhivananFailing to plan is Planning to fail |
 |
|
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-05-28 : 22:22:56
|
| webfred: thanks, i added commit transaction and it works now. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-05-29 : 04:06:16
|
Welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|