Last post Apr 27, 2018 03:37 AM by Deepak Panchal
Apr 26, 2018 05:12 AM|Naveed___|LINK
We are having one table as below, we need to update In and Out based on employee number and Officepunch , i.e first record of table will be "In" based on employee number and Officepunch.
RDISPL10 2017-04-19 06:55:30.000 IN
RDISPL10 2017-04-20 06:53:02.000 IN
RDISPL10 2017-04-21 06:54:19.000 OUT
Original Table is as below.
Kindly help in meeting above requirement.
Apr 27, 2018 03:37 AM|Deepak Panchal|LINK
Instead of updating the value, I think you need to change your logic and you need to set the value for INOUT at insertion time.
Here, I assume that there is only two entries in table. One for IN and other for OUT.
At the time of insertion, You can check that whether there is any entry exist for this particular employ for today's date or not.
If there is no entry exist then you can insert the INOUT value as IN.
Same way, again check for the particular employee for today's date. If there is any entry exist then insert the new record with INOUT value as OUT.
You can use IF..ELSE in your query.
ELSE (IF...ELSE) (Transact-SQL)
As per my understanding this is the suitable way to handle this issue.