Solved

Using LIMIT ms sql

Posted on 2013-11-26
7
171 Views
Last Modified: 2013-12-16
Hi!

Have this line of sql for mysql

How to write this same line using MS SQL ?

$sql = $sql." ORDER BY ControlID LIMIT {$offset}, {$rec_limit}";

Open in new window

0
Comment
Question by:team2005
  • 3
  • 2
  • 2
7 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39679607
What version of SQL Server are you using?  The T-SQL will vary depending on the version.
0
 
LVL 40

Accepted Solution

by:
Sharath earned 500 total points
ID: 39679611
$sql = $sql." ORDER BY ControlID OFFSET {$offset} ROWS FETCH FIRST {$rec_limit} ONLY";
0
 
LVL 2

Author Comment

by:team2005
ID: 39679949
Hi!

Tryed your code Sharah..

Get this error message

[Microsoft][SQL Server Native Client 11.0][SQL Server]Unclosed quotation mark after the character string ' ORDER BY ControlID OFFSET 0 ROWS FETCH FIRST 10 ONLY'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Unclosed quotation mark after the character string ' ORDER BY ControlID OFFSET 0 ROWS FETCH FIRST 10 ONLY'. ) )
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 40

Expert Comment

by:Sharath
ID: 39679955
As asked by acperkins, let us know your SQL Server version.
0
 
LVL 2

Author Comment

by:team2005
ID: 39680096
SQL versjon is 2012
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39681216
If it really is SQL Server 2012 then what is the Compatibility Level for this database?
0
 
LVL 2

Author Closing Comment

by:team2005
ID: 39721523
you give me olmost the solution
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now