Click here to Skip to main content
15,883,763 members

Comments by Corporal Agarn (Top 200 by date)

Corporal Agarn 12-Feb-16 6:30am View    
Try rewriting using the suggestions above
Corporal Agarn 12-Feb-16 6:28am View    
You need to learn how the code presented by Sascha Lefevre works
Month would be set @m1 = MONTH(DATEADD(DD,-4,@TO_DATE)) do you think you can get year?
Corporal Agarn 20-Jan-16 14:33pm View    
The way I read it you are going to be adding a lot more records than you think.
How is inserted related to table2? You also need to list the insert columns (best practice).

I came up with something like this:
INSERT INTO table3 (logid, servicetype, servicename)
SELECT ROW_NUMBER() OVER(ORDER BY t2.servicename ASC) AS rowno,
t2.servicename, t2.servicetime
FROM inserted i
INNER JOIN table2 t2 ON i.??? = t2.???
WHERE t2.servicetime >= DATEADD(mi,-@tolerancetime,GETDATE())
Corporal Agarn 13-Jan-16 11:39am View    
1) what is your table structure
2) what is your criteria for duplicate
Corporal Agarn 18-Nov-15 9:13am View    
Why use the cursor?