Archive

Posts Tagged ‘MSSQL’

Limit function in MSSQL 2000

November 28th, 2009

Since there is no real limit functionality in MSSQL 2000 , getting a selection of records can be somewhat difficult. Well, here’s a solution to get a number of records that works like the “limit” function that can be found in MsSQL

SELECT col FROM (
   SELECT top 50 * FROM (
      SELECT top 200 * FROM tbl1
      WHERE col > 1 ) ORDER BY col
   ) AS newtbl1 ORDER BY coldesc
) AS newtbl2 ORDER BY col ASC

Note that there is a similiar limit function in MSSQL 2k5 called “rownumber” which makes returning the desired results a lot easier. ;/

HappyFace Retarded code , , , , , ,

[MSSQL] Updating a column with values from another column

September 22nd, 2009
UPDATE Table1
SET columnToUpdate = columnToUpdateFrom

HappyFace Retarded code

[MSSQL] Check if a value in a column is numeric

September 21st, 2009

To show numeric values from a column only you can do:

SELECT column1 FROM table1
WHERE isnumeric(column1) = 1

Or if you want to show non numeric values from a column you can do:

SELECT column1 FROM table1
WHERE isnumeric(column1) = 0

HappyFace Retarded posts