Ideally it should pick up the group the user belongs to, and update the
correct record.
CREATE PROCEDURE RadSetLastUsed AS
CREATE TABLE #tmpusers
(
Username VARCHAR(32),
CallDate DATETIME
)
INSERT INTO #tmpusers (Username,CallDate)
SELECT Username=CASE WHEN CharIndex('@',username) > 0 Then
left(username,CharIndex('@',username)-1) ELSE username END,MAX(CallDate)
FROM Calls
WHERE CallDate > DATEADD(dd,-1,getdate())
GROUP BY Username
UPDATE sa
SET sa.LastUsed = t.CallDate
FROM SubAccounts sa, #tmpusers t
WHERE sa.Login = t.Username
DROP TABLE #tmpusers
Regards,
Graeme
---Graeme Slogrove, BSc (Eng) Elec (Wits)Director, Systems Development & Value Added ServicesNetActive InternetTel: 011-719-0333 Fax: 011-719-0444Support: 011-719-0300
For more information about this list (including removal) go to:http://www.iea-software.com/support/maillists/liststart