Tuesday, August 7, 2007

How to select number of rows from table in sql server

Hello

Here are two ways to select number of rows when count is passed in parameter

1. using TOP

declare @count int

set @count = 5

select top(@count) * from temp_Users


2. using ROWCOUNT


declare @count int

set @count = 5

set rowcount @count

select * from temp_Users


Please comment more ways of performing this functionality.

set rowcount 0

No comments: