
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to write a MySQL “LIMIT” in SQL Server?
You need to use TOP(1) in SQL Server. The syntax is as follows −
SELECT TOP(1) *FROM yourTableName WHERE yourCondition;
To understand the above syntax, let us create a table. The query to create a table is as follows −
create table TopDemoInSQLServer ( Id int, Name varchar(10) );
The snapshot of creation of table is as follows −
Insert some records in the table using insert command. The query is as follows −
insert into TopDemoInSQLServer values(10,'John'); insert into TopDemoInSQLServer values(14,'Carol'); insert into TopDemoInSQLServer values(1,'Sam'); insert into TopDemoInSQLServer values(11,'Bob'); insert into TopDemoInSQLServer values(18,'David'); insert into TopDemoInSQLServer values(20,'Sam');
The snapshot of insert record in the table is as follows −
Display all records from the table using select statement. The query is as follows −
select *from TopDemoInSQLServer;
The snapshot of displaying all records from the table is as follows −
Output
Here is the query to implement TOP(1) instead of LIMIT 1 −
select TOP(1) *from TopDemoInSQLServer where Name = 'Carol';
Here is the snapshot of query −
Here is the snapshot of sample output −
- Related Articles
- MySQL LIMIT clause equivalent for SQL SERVER?
- Difference between MySQL and SQL Server
- Equivalent of SQL Server IDENTITY Column in MySQL?
- How to Rename SQL Server Schema?
- How to Setup Compatibility in Microsoft SQL Server?
- The equivalent of SQL Server function SCOPE_IDENTITY() in MySQL?
- SQL Query to Convert Rows to Columns in SQL Server
- Generate table DDL via a query on MySQL and SQL Server?
- Database Wars: MSSQL Server, Oracle PL/SQL and MySQL
- How to Update Two Tables in One Statement in SQL Server?
- Mean and Mode in SQL Server
- Check Constraint in MS SQL Server
- Does SQL Server have an equivalent to MySQL's ENUM data type?
- How to restart MySQL server?
- Data Replication from SAP PO to SQL Server

Advertisements