• Programming

    Posted on December 16th, 2009

    Written by Emad Ibrahim

    Tags

    , , ,

    Select Random Records Using Nhibernate

    Selecting 5 random rows in SQL is easy select top 5 * from users order by newid() .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode [...]

  • Programming

    Posted on July 10th, 2008

    Written by Emad Ibrahim

    Tags

    , , , , , ,

    Database Schema Compare & Upgrade

    I spent a few days playing with Ruby on Rails a while back.  During the learning experience, there was one particular feature that I really liked.  It was the database migration scripts that get automatically generated for you.  I always wished I had something like this in the windows (asp.net) world.  It turns out there [...]

  • Programming

    Posted on May 12th, 2008

    Written by Emad Ibrahim

    Tags

    , , , ,

    Dynamically Build LINQ Queries Using Reflection

    I was recently working on a project where there was an option to export data from the database.  The export function simply exported 2 hard-coded columns that were returned by a stored procedure into a tab-delimited text file.  The sproc looked something like select id, name from mytable (I am over simplifying of course).  I [...]

  • Random

    Posted on June 8th, 2007

    Written by Emad Ibrahim

    Tags

    Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

    I had to uninstall and reinstall SQL server 2005 and Express on my development machine. After the un-installation, I reinstalled SQL 2005 standard then SQL Express. When I tried to open a SQL express database in VS2k5 I got the error “Failed to generate a user instance of SQL Server due to a failure in [...]

  • Random

    Posted on May 25th, 2007

    Written by Emad Ibrahim

    Tags

    Custom sort order in a SQL statement

    I tracked a status of a record in a text field and wanted to sort the results in a specific order. For example I want “active” to show before “rejected” and “deleted” to show up last, etc… It turns out it was pretty easy to do in SQL. Here it is: select * from viewoffers [...]

  • Older Posts Yeah! There are more posts, check them out.