Last post Dec 19, 2019 06:10 PM by limno
Dec 19, 2019 08:51 AM|demoninside9|LINK
I am creating user log report.
here I am inserting the data using procedure.
set @login_time=DATEADD(MI, 330, SYSUTCDATETIME())
INSERT INTO tblUserAudit (user_name,login_time,location,module_visited,browser_name)
In my data base some how I get double entry with a small difference of time (It may be greater difference if a user login in 2 times or n number of times), I am unable to understand how this difference comes. like in this case it is "2019-12-19
12:37:36.783" and "2019-12-19 12:37:36.457". I don't know why even I am just calling my methods only for ones.
Then I select the data using below query .
SELECT DISTINCT log_id, user_name,login_time,location,module_visited,browser_name
ORDER BY login_time desc
But distinct doesn't work for time. See the image below. And see the records marked with the red
Please give share the solution how can I restrict it to insert the duplicate records OR how to use distinct with the above query.
Dec 19, 2019 05:12 PM|limno|LINK
Most likely your application execute your code twice. You should handle the case from your application.
Dec 19, 2019 05:38 PM|PatriceSc|LINK
What if you try to double click the login button ?
Dec 19, 2019 06:10 PM|limno|LINK
You need to handle this case in your click event code.