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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 duplicate check

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2014-08-01 : 00:20:06
Hi all,

is there any way to check if there are any duplicate transaction within 5 minutes based on trans_no.

I will have to allow duplicates based on last transaction time

please suggest

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-08-01 : 09:22:39
quote:
Originally posted by sanjay5219

Hi all,

is there any way to check if there are any duplicate transaction within 5 minutes based on trans_no.

I will have to allow duplicates based on last transaction time

please suggest



Assuming you mean transactions in your business logic (as opposed to transaction in the T-SQL sense), something like this:
SELECT transaction_id 
FROM YourTable
WHERE transaction_time > DATEADD(mi,-5,GETDATE())
GROUP BY transaction_id
HAVING COUNT(*) > 1
Go to Top of Page
   

- Advertisement -