Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 One second update

Author  Topic 

ddobbertin
Yak Posting Veteran

51 Posts

Posted - 2007-10-18 : 17:59:01
I have an issue with a database where records are grouped together by an in house system by user login times - HH:MM:SS AM/PM. The issue is that on rare occasions the login times are input and then the subsequent records are listed as 1 second later (I am guessing just a wierd timing issue during the insertion because of CPU utilization). Here is the basic recordset:

Username - 11:59:59 AM
Username - 12:00:00 PM
Username - 12:00:00 PM
Username - 12:00:00 PM
Username - 12:00:00 PM

I need to update all records to the 11:59:59 AM time - Any ideas????
I know it's a weird one but there is more data in the record and these times are the only thing tying them together in the DB.

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2007-10-18 : 18:33:29
I'm not 100% how you determine which to update, but maybe this will help?
DECLARE @T TABLE (LogEntry VARCHAR(50))
INSERT @T
SELECT 'Username - 11:59:59 AM'
UNION ALL SELECT 'Username - 12:00:00 PM'
UNION ALL SELECT 'Username - 12:00:00 PM'
UNION ALL SELECT 'Username - 12:00:00 PM'
UNION ALL SELECT 'Username - 12:00:00 PM'

UPDATE @T
SET LogEntry = LEFT(LogEntry, CHARINDEX('-', LogEntry) - 2) + ' - 11:59:59 AM'
WHERE LogEntry NOT LIKE '%11:59:59 AM'
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-19 : 01:58:21
See also: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=87741
Go to Top of Page
   

- Advertisement -