Click to See Complete Forum and Search --> : LIMIT in MSSQL


bp_travis
10-27-2008, 11:06 AM
Hello. I am converting a script I have to MSSQL from MySQL. It all was going well till I ran into a MySQL query with a LIMIT statement. I need those LIMIT statements in my script. So, how can I achieve the same affect in MSSQL. Here is the MySQL script:
SELECT * FROM reg_data LIMIT 2,1

Thanks

starheartbeam
10-27-2008, 03:18 PM
The MS SQL eqivalent to the MySQL LIMIT is TOP.

Here is an example:

MySQL:
SELECT*FROM something LIMIT 10;
MS SQL:
SELECT TOP 10 * FROM something;

Also, I found this query, which claims to have the same effect as the LIMIT clause:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=850&lngWId=5