Home > Ask the SQL Server Experts > Archive: Integration Services Questions & Answers > SQL Server features to identify rows in a table
Ask The SQL Server Expert: Questions & Answers
EMAIL THIS

SQL Server features to identify rows in a table

Joe Toscano EXPERT RESPONSE FROM: Joe Toscano

Pose a Question
Other SQL Server Categories
Meet all SQL Server Experts
Become an Expert for this site


Expert advice on database development
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 01 June 2006
As there is Rowcount and Rownum in Oracle to identify rows in a table, what is available in SQL Server?

>
You have ROWCOUNT, which is a session-level global variable. You can check this value after an insert, update, delete or select and it will return the number of rows affected by the last statement. As for row numbers you will have to work with SQL Server 2005 to take advantage of this new feature. If you are running SQL Server 2005 and installed the AdventureWorks database, here's an example:

The ROW_NUMBER function returns the ordinal row position of each row in a grouping within a result set. This function can be very useful for generating reports.

select ROW_NUMBER()
 over(PARTITION BY PC.Name ORDER BY ListPrice) as Row,
 PC.Name Category, P.Name Product,  P.ListPrice
From Production.Product P
JOIN Production.ProductSubcategory PSC
on P.ProductSubCategoryID = PSC.ProductSubCategoryID
JOIN Production.ProductCategory PC
on PSC.ProductCategoryID = PC.ProductCategoryID 


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
Archive: Integration Services
How to convert DTS packages to SSIS and overwrite data
How to migrate DTS to SSIS and deploy SSIS packages
Query to search text in old DTS packages in SQL Server?
Error importing Excel data to SSIS in SQL Server 2005
Delete .bak files automatically with CLR
DTS package designed to overwrite extract.xls
Displaying a SQL Server database report in Excel
Stored procedure practices in SQL Server
Call triggers in a stored procedure
SQL Server permission to create jobs and schedules in SSIS

Microsoft SQL Server Database Development
Change tempdb from 'C' drive
Sub-queries supported in Analysis Services MDX
MDX functions: SCOPE, THIS and FREEZE
More powerful Analysis Services MDX in SQL Server 2005
Top 5 SQL Server query tips
Update table rows in SQL Server 2000
Delete .bak files automatically with CLR
Conversion error in SQL Server business objects
Syntax error in SQL Server script
Stored procedure overview in SQL Server
Microsoft SQL Server Database Development Research

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



SQL Solutions - SQL Database Design
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts