e enjte, 7 shkurt 2008

Some SQL Stuff....

Ways you could you limit the number of records returned by SQL query?

There are 2 ways you can do that,

1. set ROWCOUNT to the required number of rec
2. Use TOP in select query

What's the difference, well not much except ROWCOUNT will override TOP if latter value is less. And ROWCOUNT affect subsequent queries.

One of areas ROWCOUNT comes in picture is say you need a Stored Procedure in which you are passing number of records your query must return as a parameter (@paramcnt), here TOP will not be of much use as you cannot have query like 'SELECT TOP @paramcnt FROM ...' but you definitely can put 'set ROWCOUNT @paramcnt', thats my observation......share yours.

Nuk ka komente: