Posts about using the database server MS SQL.

Round A Number In MS SQL

10th November 2008 - 1 minute read time

To round a number in MS SQL use the ROUND() function. This function takes two parameters, the first is the number to be rounded and the second is the number of decimal places to round the number to. Here is an example of rounding the numbers in a column to the nearest whole integer.

Read the full article

Limit Number Of Rows Returned In MS SQL

23rd September 2008 - 1 minute read time

To limit the number of rows returned in a MS SQL query you need to use the TOP command. This goes before you name the columns that are to be returned by the SELECT statement.

The following query returns the first 35 rows from a table.

Read the full article

Getting A Random Row From A MS SQL Table

9th January 2008 - 1 minute read time

To get a random row from a Microsoft SQL database you need to use the NEWID() function. This will generate a new random number for each row and order them by that new number. This is used in conjunction with the TOP clause to limit the amount of returned rows to one.



Read the full article