Tuesday, May 30, 2006


How to display number of records, data and index space in Microsoft SQL Server

I got the great query below from Michele today. It shows all the information you ever wanted to know about the tables in your SQL Server, in particular; the number of rows as well as the size of the data and index.

DECLARE @Tab sysname




from sysobjects

WHERE xType='u'


OPEN tables_Cursor


      FETCH NEXT FROM tables_Cursor INTO @tab




      select @tab
      -- Show space used by table

      exec ('sp_mstablespace ''' + @tab + '''')

      -- Show generic table info

      exec ('sp_help ''' + @tab + '''')

      FETCH NEXT FROM tables_Cursor INTO @tab



CLOSE tables_Cursor

DEALLOCATE tables_Cursor

Sunday, May 28, 2006


Hit hard by mail spam

Until May I received very little mail spam as I use a different email alias for each subscription, forum, etc. When a company sells my address to a spammer I know who the they are, who to complain to and I just delete all mails to the spammed alias.

But, the spammers just started doing something that makes my life a lot more difficult. They send a lot of fake mail that looks like they come from egilh.com. In many cases the targeted account does not exist so I get a Non-delivery report (NDR) message back. Below is one example:

We're sorry. There's a problem with the e-mail address(es) you're trying to send to. Please verify the address(es) and try again. If you continue to have problems, please contact Customer Support at (480) …..

The e-mail message could not be delivered because there are no users here by that name.

--- Below this line is a copy of the message.

Return-Path: <spam@egilh.com>
Received: (qmail 18739 invoked from network); 18 May 2006 12:16:13 -0000
Received: ....secureserver.net) ([64.202….])
        (envelope-sender <spam@egilh.com>)
        by ....prod.mesa1.secureserver.net (qmail-ldap-1.03) with SMTP
        for <...@cimbom.com>; 18 May 2006 12:16:13 -0000
Received: (qmail 12824 invoked from network); 18 May 2006 12:16:13 -0000
Received: from unknown (HELO ....ttnet.net.tr) ([88.226….])
        (envelope-sender <spam@egilh.com>)
        by ....prod.mesa1.secureserver.net (qmail-ldap-1.03) with SMTP
        for <...@cimbom.com>; 18 May 2006 12:16:06 -0000
Received: from [88.226….] (helo=dlxf)
by dsl88-226-16268.ttnet.net.tr with smtp (Exim 4.43)
id 1FghUk-0004QU-Uj; Thu, 18 May 2006 15:20:46 +0300
Message-ID: <001301c67a74$d0130457$677be258@dlxf>
From: "Paula Fry" <spam@egilh.com>
To: <...@cimbom.com>
Subject: Democrat

In the past I have always complained to the ISP of the spammers but in this case I am fighting a loosing battle as the mails are sent by different IP addresses all over the world. One of the worst Internet Service Providers in my experience is ttnet.net.tr. I have lost count of the mails I have sent to their "abuse" alias without any reply or sign of improvement:-(

A lot of the mails bounce back to me as a Non-delivery report which is bad, but some of the mails hit a real mail account which is even worse. Does anybody out there have any suggestions regarding what to do in these cases?

  • Does SPF actually work? I have only seen a couple of mails with SPF headers.
  • Someone suggested forwarding the spam to spam@uce.gov, and adding a the reference to Federal Can Spam Act, 2003.
  • Bounce the NDR back to the sender. That is not really fair as postmasters all over the world will get NDRs from my domain (at the moment I silently drop the NDRs for accounts that do not exist on my domain). NDRs seem to be a popular way of spreading spam as Jeff Atwood has a related problem.

Suggestions anyone?

Updated: fixed broken link to SPF

Tuesday, May 23, 2006


Italian Java Conference 2006 with James Gosling

The Italian Java conference 2006 will be held in Roma 26/6 and in Milano 27/6-28/6

James Gosling, the man behind Java, will attend the Italian event for the first time ever. Gosling is Vice President, Fellow and Chief Technology Officer of the Developer Products Group of Sun and is working in the Real-Time Specification for Java.

Web 2.0 will be he main theme of the Java Conference 2006 with the changes the "Participation Age" implies; Software as a Service, Open Source, Service Oriented Architecture and Ajax.

Friday, May 19, 2006


About egilh

I worked for Microsoft on DOS 6.2, Excel 6 and Windows 95 before I moved to Italy. I made my living as Software Architect/Lead Developer working for Iris (which has joined the Reply group) for more than a decade on Java and .NET projects in the Italian telecommunications and media industry.

My programming experience ranges from office automation to device drivers in assembler in a wide range of languages; C#, Java, VB.NET, VB, Perl, C, C++, PowerBuilder, VBA and Assembler as well as DB design. Most of my work is done on Windows but I have also worked on Solaris and mainframe solutions. I have a long experience designing large online systems in Java and .NET with strict SLAs regarding uptime and response times, but I also enjoy the challenge of mobile devices due to the form factor and limited capabilities.

At the moment I work in Milan, Italy, for 10100.

**This is my personal blog. The views expressed on these pages are mine alone and not those of my employer.**

You can get the latest version of my free tools in the downloads area.

Tuesday, May 16, 2006


Solving Sudoku puzzles with T-SQL

Now this is a creative use of Microsoft SQL Server stored procedures: solving Sudoku puzzles:

To make it even more fun for myself, I embarked on an exercise to write a program that solves Sudoku puzzles. And to make it even more challenging I decided not to write the program in the popular object-oriented fashion (Java, C++, C#, etc.) or in any of the old-fashioned procedural programming languages (Pascal, C, Basic etc); but in Transact SQL, within SQL Server 2000. Basically, I wanted to see how the features of T-SQL can be used to develop something like a Sudoku puzzle solution. I have learnt some useful things from the exercise, which I’m eager to pass on to my fellow programmers.

SQL Server 2005 makes even simpler as it is possible to write stored procedures with .NET

Thanks for the tip Marco

Monday, May 8, 2006


FileSystemWatcher does not work with DFS on Win2k3

The ASP.NET cache can be used from any .NET program, but for several reasons I had to make my own caching system of a configuration file. In theory it works; my cached object will automatically be removed when the file has been changes. There are multiple worker processes and each of them use a FileSystemWatcher to notice if there are any changes to the configuration file:

private static System.IO.FileSystemWatcher _watcher = null;
_watcher = new System.IO.FileSystemWatcher(HttpContext.Current.Server.MapPath("."), MY_CONFIG_FILE);                       
_watcher.Changed += new FileSystemEventHandler(callbackConfigChanged);
_watcher.EnableRaisingEvents = true;

I developed the code on the same OS as the production environment (Win2k3) but I still came across an unexpected problem during testing in a pre-production environment. The server farm use DFS to synchronize the web site as well as my configuration file.  The FileSystemWatcher works perfectly on the machine where I modify the configuration file but the other machines in the server farm using FileSystemWatcher do not-get notified of changes in DFS.

It is possible to work around the problem by checking a time stamp but for now we do a manual file save operation on each machine until the problem gets fixed


ASP.NET error: Maximum request length exceeded

If you post large data to a web service or a aspx file using a form you may get this error message:

System.Web.HttpException: Maximum request length exceeded.
   at System.Web.HttpRequest.GetEntireRawContent()
   at System.Web.HttpRequest.get_InputStream()
   at com...ProcessRequest(HttpContext context)

The problem is that .NET limits the maximum data sent in each request to 4MB by default. The size can be changed to any value you want in machine.config or in web.config by configuring the httpRuntime maxRequestLength:

httpRuntime Attributes:
    maxRequestLength="[KBytes]" - KBytes size of maximum request length to accept

Friday, May 5, 2006


Call me Darth Vader

You can call me Darth Vader after the sounds I made last night…

A month or so ago, I started experiencing some of the symptoms of hay fever / pollen allergy: sneezing, itching nose and eyes, runny nose (occasionally nosebleeds) and impaired smell. I have been taking a non prescription medicine every other day lately which has helped a lot. Until I got creative yesterday and stopped taking it as I felt a lot better. I wish I had not, as I can now add another symptom to the list: wheezing:

During an asthma episode, inflamed airways react to environmental triggers such as smoke, dust, or pollen. The airways narrow and produce excess mucus, making it difficult to breathe.

It was a scary experience that makes me feel sorry for people with serious Asthma problems. The doc gave me some pills that should keep the allergy at bay and an inhalator that should help me breath if I start wheezing again.

A learning by doing lesson I whish I had skipped.