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 [...]
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 [...]
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 [...]
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 [...]
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 [...]
Wednesday, December 16, 2009
View Comments