Thursday, July 26, 2007

Replacing dates to sortable strings in SQL

Try this:

select replace(replace(convert(nvarchar(19),@Date,120), ':',''), ' ', '_')

Monday, July 23, 2007

Yet another Windows WTF

I am now working on a brand-new machine, running Windows XP 64 bit, with 4GB of physical memory. Being a big fan of hibernation, I wanted to set my system to support it. Guess what - it's not supported!

A quick check on Google showed me this:

"

This issue occurs because hibernation is disabled on computers that have more than 4 GB of RAM.
Hibernation requires sufficient disk space to contain the contents of the computer's memory. Performance is poor on a computer that has more than 4 GB of memory and that has support for hibernation. Therefore, Microsoft has disabled support for hibernation on such computers.

"

The source, BTW, is from Microsoft's knowledge base.

Now you tell me - why do they decide for me what performance is unacceptably poor and what is not? If I have 10GB of ram, I know that hibernation will be slow, and if I choose to use it anyway - it's my decision to take, not MS's!

I haven't tried the workaround proposed yet, we'll see if it helps...

Sunday, July 22, 2007

Enabling xp_cmdshell in SQL Server 2005

It is already known to every SQL newbie that the system xp_cmdshell stored procedure is a huge hole in SQL security. Basically, it allows anyone with permissions to run it to be able to execute shell commands on the SQL machine. To provide a more secure system, in SQL 2005, this stored procedure is not available by default (unlike SQL 2000).

To enable this stored procedure, you should run the following script (for more details about the permissions required see here and here):

exec sp_configure 'show advanced options', 1
go
reconfigure
go
exec sp_configure 'xp_cmdshell', 1
go
reconfigure
go



REMEMBER - this is extremely dangerous and exposes your server to a wide variety of attacks, so be careful!

Thursday, July 19, 2007

New Israeli Blogger - Ami Bar

I strongly recommend you to check out my friend and colleague, Ami Bar's, new blog. He's just started, but now that we are once again working together I intend to push him into blogging as much as possible. Believe me - this guy knows stuff you'll want to know!

Just to show you why, check out his excellent SmartThreadPool on Codeproject.

Good luck, Ami, and may the Schwartz be with you!

Wednesday, July 18, 2007

Changing the number of maximum Internet connections

I know it's an old story, but every time I need it I have to go and search for this information, so I'm posting it here for later reference.

For a reason I don't know (and don't really care), Windows limits the number of concurrent Internet connection available (with XP I think you get 2 concurrent connections in HTTP 1.0 and 4 in HTTP 1.1).

With contemporary computers and the bandwidths of these days, this limitation is archaic to say the least.

So, if you need to be able to handle more simultaneous connections, you just need to add two entries to the registry. To simplify it, just copy the following lines to a file with a .reg extension and then double-click it. It will change the configuration to allow 50 simultaneous connections ;-)

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"MaxConnectionsPerServer"=dword:00000032
"MaxConnectionsPer1_0Server"=dword:00000032