

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- MySQL LIMIT clause equivalent for SQL SERVER?
- Difference between MySQL and SQL Server
- Equivalent of SQL Server IDENTITY Column in MySQL?
- The equivalent of SQL Server function SCOPE_IDENTITY() in MySQL?
- Generate table DDL via a query on MySQL and SQL Server?
- Database Wars: MSSQL Server, Oracle PL/SQL and MySQL
- Mean and Mode in SQL Server
- Difference between Oracle and SQL Server
- Data Replication from SAP PO to SQL Server
- How to restart MySQL server?
- Does SQL Server have an equivalent to MySQL's ENUM data type?
- Difference between ETL and ELT in SQL Server
- MySQL LIMIT to select a single row
- How to run SQL script in MySQL?
- How to copy tables or databases from one MySQL server to another MySQL server?
Advertisements