Try this:insert into LoginHistorySelect datePart(mm,a. Last_Connected_Date), datePart(yy,a. Last_Connected_Date), a.Res_UID,null,1 from Logins a--where a.Last_Connected_Date is not null and not exists(select * from LoginHistory b where a.Res_UID = b.ResUID and b.MonthNo = datePart(mm,a. Last_Connected_Date) and b.YearNo = datePart(yy,a. Last_Connected_Date))
No, you're never too old to Yak'n'Roll if you're too young to die.