Wednesday, August 27, 2008

T-SQL Performance of the DatePart function

I recently have had some trouble with speed on one of my queries. Suspecting it might be a DatePart function I was applying to every row of retrieved data I wrote a little performance test and was pleasantly surprised at how efficient DatePart was:

[code]

declare @loop int, @temp varchar(10), @datestamp datetime
set @loop=1
print convert(varchar(100),getdate(),113)
set @datestamp = getdate()
while @loop < 1000000
begin
set @loop = @loop + 1
set @temp = DatePart(q, '08/27/2008')
end

print convert(varchar(100),getdate(),113)
print datediff(ms, @datestamp,getdate())

set @datestamp = getdate()
set @loop=1
while @loop < 1000000
begin
set @loop = @loop + 1
set @temp = ''
end
print convert(varchar(100),getdate(),113)
print datediff(ms, @datestamp,getdate())

[/code]

[results]

27 Aug 2008 15:23:12:293
27 Aug 2008 15:23:14:200
1906
27 Aug 2008 15:23:15:983
1783

[/results]

so the DatePart function only added a little more than 100 milliseconds to the processing time.

Thursday, August 14, 2008

Windows updates failing to install

I recently had an issue where my windows updates simply failed to install. They would download just fine but never installed.

I found a fix here:
[quote]
Go here and see if it works

http://www.microsoft.com/genuine/

fix any issues, then validate it.

If it still doesn't work try this

Re-register the Windows Update DLL with the commands below
Click Start, click Run, type cmd, and then click OK.
Type the following commands. Press ENTER after each command.
regsvr32 wuapi.dll
regsvr32 wuaueng.dll
regsvr32 wuaueng1.dll
regsvr32 wucltui.dll
regsvr32 wups.dll
regsvr32 wups2.dll
regsvr32 wuweb.dll

Attempt to run Windows Update

Now what do you get?
[/quote]

The problem in the thread had a different source than mine, he had cloned his OS onto a new HD. In my case I had a fresh install of WinXP that was barely a month old.