Category: Archive

Engineering notes from 2008–2014: SQL Server scripts, DBA quick-tips, and field notes from the trenches. Preserved as written — the foundation everything since was built on.

  • An Apple in the Bag

    Dear Readers,

    Good Story, please read it.

    A teacher teaching Maths to seven-year-old Arnav asked him, “If I give you one apple and one apple and one apple, how many apples will you have?”Within a few seconds Arnav replied confidently, “Four!”

    The dismayed teacher was expecting an effortless correct answer (three).  She was disappointed.  “Maybe the child did not listen properly,” she thought.  She repeated, “Arnav, listen carefully.  If I give you one apple and one apple and one apple, how many apples will you have?”

    Arnav had seen the disappointment on his teacher’s face.  He calculated again on his fingers.  But within him he was also searching for the answer that will make the teacher happy.  His search for the answer was not for the correct one, but the one that will make his teacher happy.  This time hesitatingly he replied, “Four…”

    The disappointment stayed on the teacher’s face.  She remembered that Arnav liked strawberries.  She thought maybe he doesn’t like apples and that is making him loose focus.  This time with an exaggerated excitement and twinkling in her eyes she asked, “If I give you one strawberry and one strawberry and one strawberry, then how many you will have?”

    Seeing the teacher happy, young Arnav calculated on his fingers again.  There was no pressure on him, but a little on the teacher.  She wanted her new approach to succeed.  With a hesitating smile young Arnav enquired, “Three?”

    The teacher now had a victorious smile.  Her approach had succeeded.  She wanted to congratulate herself.  But one last thing remained.  Once again she asked him, “Now if I give you one apple and one apple and one more apple how many will you have?”

    Promptly Arnav answered, “Four!”

    The teacher was aghast.  “How Arnav, how?” she demanded in a little stern and irritated voice.

    In a voice that was low and hesitating young Arnav replied, “Because I already have one apple in my bag.”

    “When someone gives you an answer that is different from what you expect don’t think they are wrong.  There may be an angle that you have not understood at all. You will have to listen and understand, but never listen with your mind already made up.”

  • Create A Love Account

    Mother Teresa once said, “There are no great acts. There are only small acts done with great love.” What small acts can you do today to deepen the bonds between you and the people you value the most? What random acts of kindness and senseless acts of beauty can you offer to someone in an effort to make his or her day just a little better? The irony of being more compassionate is that the very act of giving to others makes you feel better as well.

    To practice being more loving, create a love account. Each day, make a few deposits in this very special reserve by doing something small to add joy to the life of someone around you. Buying your partner fresh cut flowers for no reason at all, sending your best friend a copy of your favorite book or taking the time to tell your children in no uncertain terms how you feel about them are good places to start.

    If there is one thing that I have learned in life, it is that the little things are the big things. Those tiny, daily deposits into the love account will give you far more happiness than any amount of money in your bank account. As Emerson said so eloquently, “Without the rich heart, wealth is an ugly beggar.” Or as Tolstoy wrote, “The means to gain happiness is to throw out for oneself, like a spider, in all directions an adhesive web of love, and to catch in all that comes.”

  • Script to find out data and log file size

    You can use below script to find out data file (*.mdf) and Log file (.ldf) size

    exec sp_helpdb [dbName]

    or

    use [dbName]
    select str(sum(convert(dec(17,2),size)) / 128,10,2) + 'MB'
    from dbo.sysfiles

  • FAQs .Net Assembly

    How is the DLL Hell problem solved in .NET?  Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly. 

    How to deploy .Net assembly? An MSI installer, a CAB archive, and XCOPY command. 

    What is a satellite assembly and what is the use of it? When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies. 

    What namespaces are necessary to create a localized application? System.Globalization and System.Resources. 

    What is the smallest unit of execution in .NET? An Assembly is the smallest unit of execution in .Net 

    When should you call the garbage collector in .NET? It is recommended that, you should not call the garbage collector.  However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory. 

    How do you convert a value-type to a reference-type? Use Boxing 

    What happens in memory when you Box and Unbox a value-type?

    Boxing converts a value-type to a reference-type, thus storing the object on the heap.  Unboxing converts a reference-type to a value-type, thus storing the value on the stack