INSERT INTO hits (recorded_time,ip,ua,request,referer,is_unique)
SELECT Convert(datetime,'2010-02-10 11:00:00'),00001001,'IE','default.aspx','direct',0
WHERE NOT EXISTS (SELECT ID FROM Hits WHERE IP=00001001);SELECT @@IDENTITY;
Above query will check the existing record of the given IP. If found than it will return the ID else it will insert the new record and than return the newly generated ID.