[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Equivalent of First() in MS-SQL

Posted on 1998-10-01
2
Medium Priority
?
249 Views
Last Modified: 2010-03-19
I want to convert a query in Access to MS-SQL Query. The Query in Access has First() function. Is there any equivalent function in MS-SQL ?
What exactly will First() do ? Is that it will pick the first record in the query (assume the query contains group by clauses) or the first inserted record in the table ?

If i want to find the first inserted record then i want to know the equivalent of rowid as in Oracle
0
Comment
Question by:vvg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:vvg
ID: 1090354
Edited text of question
0
 
LVL 1

Accepted Solution

by:
gertrude earned 60 total points
ID: 1090355
If you simply want to limit the number of rows returned from a TSQL script to 1 you can:

  SET ROWCOUNT 1   -- forces results to be limited to one record
  SELECT ......    
  SET ROWCOUNT 0   -- results will return all records

If you want to know the IDENTITY value of a record you just added to a table (assuming the table has an IDENTITY column) you can use:

  SELECT @@Identity

immediately after your INSERT statement.  Note that @@Identity is connection specific.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

649 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