user5581557 user5581557 - 6 months ago 9
SQL Question

How do I Remove an entry which is more than 30 seconds old And has null value

Objective:

Remove all
entries
where
LastLogin
is
null
AND
RegDate
is older than 30 seconds.

I'm trying to use transact SQL to remove an entry from table 'ONE'

SELECT *
FROM dbo.ONE
WHERE LastLogin == Null AND RegDate is older than DATETIME.NOW by 30 seconds;


I hope the question makes sense. So how would I achieve this?

Answer

As @Alex K. pointed out check for null and using datediff

select * from dbo.ONE where LastLogin is NULL and  
                            datediff(ss,regdate,GetDate())<30
Comments