-- Only add the new column if it doesn't exist.
IF NOT EXISTS (
SELECT Object_ID FROM sys.columns
WHERE Name = N'DateTimeStamp' and Object_ID = Object_ID(N'dbo.tblLog')
)
BEGIN
-- Add a new column to store a proper datetime value.
ALTER TABLE dbo.tblLog
ADD DateTimeStamp DATETIME
-- Get the char dates for conversion into proper datetime objects.
DECLARE DateList CURSOR FOR
SELECT date, hour FROM dbo.tblLog FOR UPDATE OF DateTimeStamp
-- Loop variables
DECLARE @Date CHAR(20)
DECLARE @Hour INT
-- Loop thorugh and update the new column with the current row date string as a proper datetime.
OPEN DateList
FETCH NEXT FROM DateList
INTO @Date, @Hour
WHILE @@FETCH_STATUS = 0
BEGIN
UPDATE dbo.tblLog
SET DateTimeStamp = CONVERT(DATETIME, SUBSTRING(@Date, 7, 4) +
'-' + SUBSTRING(@Date, 4, 2) + '-' + SUBSTRING(@Date, 0, 3) +
' ' + CONVERT (CHAR(2), @Hour) + ':00:00')
WHERE CURRENT OF DateList
FETCH NEXT FROM DateList INTO @Date, @Hour
END
-- Clean up.
CLOSE DateList
DEALLOCATE DateList
END
SELECT * FROM dbo.tblLog
Showing posts with label multiple. Show all posts
Showing posts with label multiple. Show all posts
Thursday, 3 December 2009
Wednesday, 22 October 2008
Multiple page life cycles for no reason?
Have you ever debug your ASP.NET code and noticed your breakpoint in the Page_Load event is hit multiple times, even though it should only execute once?
If you have any links with # as the navigation url this can happen as a request is sent each time to the server.
If you have any links with # as the navigation url this can happen as a request is sent each time to the server.
Subscribe to:
Posts (Atom)