Stored procedure to find the biggest tables in the database

UPDATE: The sp_SOS procedure is not working with the latest versions of SQL Server.

Use Stored procedure to identify the top n biggest tables in a database instead


To find the biggest tables in the SQL Server database I am using good stored procedure


EXEC dbo.sp_SOS @OrderBy=‘T’ 

/*downloaded from
The related article “Find size of SQL Server tables and other objects with stored procedure

Valid @OrderBy parameters are:

‘N’ –> Listing by object name

‘R’ –> Listing by number of records

‘T’ –> Listing by total size

‘U’ –> Listing by used portion (excluding free space)

‘I’ –> Listing by index size

‘D’ –> Listing by data size

‘F’ –> Listing by unused (free) space

‘Y’ –> Listing by object type


It’s a start point before you will Archive Old data or consider to Partition table (see Sql Server 2005 – Twelve Tips For Optimizing Query Performance by Tony Wright)



3-D Secure credit card verification Links


The Process Flow described in “3-D Secure. Further Technical Information”

Using delicious to mark links “To follow-up”

I am using delicious to save bookmarks with tags, that describe the type of link(e.g. ASP.NET,AJAX etc), but not so often to find my own bookmarks.
However often I want to make a note for particuler page, that I need to return back  to read, print,copy code etc.

For a long time I’ve used iGoogle gadget “TO-DO list” to save URLs to follow up, but it is not really convinient for URLs, and also required to save the URLs in 2 places.

Recently I’ve got an idea, that I can have extra delicious tag/tags like “ToDo” or “ToPrint”. 
Then I’ve added iGoogle gadget Bookmarks filtered by my “ToDo” tag to my  Google homepage.
It works quite well.
When I finish what I wanted to do, I am just removing “ToDo” tag from the stored link.
Ideally I want to see Bookmarks gadget to have an additional abilty to open delicious bookmark instead of the linked article,

Insert CSS link with updatable version number in URL

More than a year ago I wrote a post Code Render Blocks does not work inside HEAD server controls about the problem, that prevented me to update URL of CSS file, when version of assembly incremented.
Now I’ve created a function  

       /// <summary>
        /// </summary>
        /// <param name="page"></param>
        /// <param name="cssFileHref">e.g. "~/StyleSheet.css"</param>
        /// <returns></returns>
        public static HtmlLink AddStyleSheetLink(this Page page, string cssFileHref)
            if (page.Header == null) { throw new NullReferenceException("page.Header is null"); }
            HtmlLink link = new HtmlLink();
            link.Href = cssFileHref;
            link.Attributes.Add("rel", "stylesheet");
            link.Attributes.Add("type", "text/css");
            return link;

and called it from markup aspx.

<% //this.AddHeadItems();CSSHelper.AddStyleSheetLink(this,“MyStylesFile.css?v=”+Utility.AssemblyVersionNumber()); %> 

Similar function in VB has been described in StyleSheetsManage class for DotNetNuke  post.

Note that I intentionally calling it from markup instead of code behind to be able manually change URL(e.g to ?v57=”) without new version rebuild to force refresh of CSS file in client browsers.
Initially it failed with the error:
Additional information: The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>).
 , but I was able to delete code render blocks out off HEAD block.
Then I found, that if I am calling AddStyleSheetLink after <HEAD runat=”server”> block, the call has no effect and link to CSS file is not inserted.
But when I’ve put AddStyleSheetLink before HEAD, it works as expected 

<% //this.AddHeadItems();
CSSHelper.AddStyleSheetLink(this,“MyStylesFile.css?v=”+Utility.AssemblyVersionNumber()); %>

<HEAD runat=”server”>
and generates  desired html: 

 <HEAD><meta content=”Microsoft Visual Studio 7.0″ name=”GENERATOR” /><meta content=”C#” name=”CODE_LANGUAGE” /><meta content=”JavaScript” name=”vs_defaultClientScript” /><meta content=”” name=”vs_targetSchema” />
<link href=”MyStylesFile.css?v=″ rel=”stylesheet” type=”text/css” />

Alternative approach suggested in automatically-version-your-css-and-javascript-files/ is to append the number to the file name itself and then use RewriteRule processor (e.g. utilizing “URL Rewriting Using ISAPI_Rewrite” )

Validate eMail address using MailAddress.ParseValue


We have Regular Expression validator to validate the eMail address, specified by the users. It usually warn user about some common mistakes. But sometimes eMail address passes validation  , but later causes exception in MailAddress.ParseValue called from MailAddress constructor.
I decided to call MailAddress.ParseValue as a part of UI validator, but it’s private. (I’ve asked MS to change it) So I had to open constructor inside try block and catch exceptions in case if format is wrong. Alternatively I could use reflection to call private MailAddress.ParseValue or copy the code from Reflector disassembly or from Mono.

                //MailAddress.ParseValue is private
            //            if(MailAddress.ParseValue(txtEmailText)
                //TODO: use Reflector or find some code to validate address as strict as ParseValue , for now just catch Exception
                        MailAddress addr=new MailAddress( txtEmailText);
            catch (Exception exc)
                Debug.Assert(false, "Investigate why ?."+exc.ToString());
                isValid = false;
                sWrongEmailMsg = "<br>This email address should be in the format of";

 Post of Craig Barber in thread The specified string is not in the form required for an e-mail address explains that MS Mail doesn’t support a dot, “.”, preceding the at-sign, “@”, e.g. . It is “right” thing according to RFC 2822, but some email providers, including gmail, earthlink, and comcast allow users to create and deliver to addresses in the aformentioned format. The users will only be confused or frustrated.