Link to home
Start Free TrialLog in
Avatar of flaki
flaki

asked on

Limit query output size in sql

Hi,
How do you fix a limit of data may the user get from MSSQL 2000 in a query?
Thanks,

Avatar of JimV_ATL
JimV_ATL

The simple answer to your question is

select top N *
from yourtable

where N is the maximum number of rows you wish to return.

If you need something different, please be more specific as to exactly how you want to what to limit.

you can also use
set rowcount @i

where @i is the number of rows.
This will terminate the select when the number of rows is reached.

Same effect as select top but allows a variable.
Avatar of flaki

ASKER

I want a limit in bytes not in rows.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of JimV_ATL
JimV_ATL

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of flaki

ASKER

thanks
I came across this and thought of your situation.  If your goal is to prevent a single query from tieing up the server, then you could use

SET QUERY_GOVERNOR_COST_LIMIT value

where value is the number of "ticks" that that connection is allowed to run a particular query.

If you wanted to set the value on a server basis, then you would use

sp_configure 'QUERY_GOVERNOR_COST_LIMIT', value.

 
flaki:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
No comment has been added to this question in more than 268 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   Accept: JimV_ATL http:#8233873

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

monosodiumg
EE Cleanup Volunteer