Sunday, February 19, 2012

Execute only and don't return results

Is there an option in SQL Server to just execute a query but don't return
it's results? The aim is to run a batch of queries to record the number of
reads they make, without having to return data back to the client, which
will take some time.
Thanks in advance.
--
Regards
Ray MondCheck the SET NOCOUNT option.
--
HTH,
SriSamp
Please reply to the whole group only!
http://www32.brinkster.com/srisamp
"Ray Mond" <yeohray@.hotmail.com> wrote in message
news:O$l1kcY2DHA.2680@.TK2MSFTNGP11.phx.gbl...
> Is there an option in SQL Server to just execute a query but don't return
> it's results? The aim is to run a batch of queries to record the number
of
> reads they make, without having to return data back to the client, which
> will take some time.
> Thanks in advance.
> --
> Regards
> Ray Mond
>|||That only turns off the 'x rows affected' message. I know of the SET
ROWCOUNT option, but would that affect the execution plan in any way? I
want the query to run to completion, I just don't want the results returned.
--
Regards
Ray Mond
"SriSamp" <ssampath@.sct.co.in> wrote in message
news:e4ZsCBa2DHA.2160@.TK2MSFTNGP12.phx.gbl...
> Check the SET NOCOUNT option.
> --
> HTH,
> SriSamp
> Please reply to the whole group only!
> http://www32.brinkster.com/srisamp
> "Ray Mond" <yeohray@.hotmail.com> wrote in message
> news:O$l1kcY2DHA.2680@.TK2MSFTNGP11.phx.gbl...
> > Is there an option in SQL Server to just execute a query but don't
return
> > it's results? The aim is to run a batch of queries to record the number
> of
> > reads they make, without having to return data back to the client, which
> > will take some time.
> >
> > Thanks in advance.
> >
> > --
> > Regards
> > Ray Mond
> >
> >
>|||Using SET ROWCOUNT could be dangerous, since execution will stop after that
many rows are reached.
--
HTH,
SriSamp
Please reply to the whole group only!
http://www32.brinkster.com/srisamp
"Ray Mond" <yeohray@.hotmail.com> wrote in message
news:eFyBi5a2DHA.2700@.tk2msftngp13.phx.gbl...
> That only turns off the 'x rows affected' message. I know of the SET
> ROWCOUNT option, but would that affect the execution plan in any way? I
> want the query to run to completion, I just don't want the results
returned.
> --
> Regards
> Ray Mond
> "SriSamp" <ssampath@.sct.co.in> wrote in message
> news:e4ZsCBa2DHA.2160@.TK2MSFTNGP12.phx.gbl...
> > Check the SET NOCOUNT option.
> > --
> > HTH,
> > SriSamp
> > Please reply to the whole group only!
> > http://www32.brinkster.com/srisamp
> >
> > "Ray Mond" <yeohray@.hotmail.com> wrote in message
> > news:O$l1kcY2DHA.2680@.TK2MSFTNGP11.phx.gbl...
> > > Is there an option in SQL Server to just execute a query but don't
> return
> > > it's results? The aim is to run a batch of queries to record the
number
> > of
> > > reads they make, without having to return data back to the client,
which
> > > will take some time.
> > >
> > > Thanks in advance.
> > >
> > > --
> > > Regards
> > > Ray Mond
> > >
> > >
> >
> >
>|||you might select count(*) instead of the other table columns... The client
will only get the number of rows that were selected.
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Ray Mond" <yeohray@.hotmail.com> wrote in message
news:O$l1kcY2DHA.2680@.TK2MSFTNGP11.phx.gbl...
> Is there an option in SQL Server to just execute a query but don't return
> it's results? The aim is to run a batch of queries to record the number
of
> reads they make, without having to return data back to the client, which
> will take some time.
> Thanks in advance.
> --
> Regards
> Ray Mond
>|||I can't do this because this will affect the execution plan.
--
Regards
Ray Mond
"Wayne Snyder" <wsnyder@.computeredservices.com> wrote in message
news:%23$F2Dnc2DHA.2208@.TK2MSFTNGP12.phx.gbl...
> you might select count(*) instead of the other table columns... The client
> will only get the number of rows that were selected.
>
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Computer Education Services Corporation (CESC), Charlotte, NC
> www.computeredservices.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
>
> "Ray Mond" <yeohray@.hotmail.com> wrote in message
> news:O$l1kcY2DHA.2680@.TK2MSFTNGP11.phx.gbl...
> > Is there an option in SQL Server to just execute a query but don't
return
> > it's results? The aim is to run a batch of queries to record the number
> of
> > reads they make, without having to return data back to the client, which
> > will take some time.
> >
> > Thanks in advance.
> >
> > --
> > Regards
> > Ray Mond
> >
> >
>|||[posted and mailed, please reply in news]
Ray Mond (yeohray@.hotmail.com) writes:
> Is there an option in SQL Server to just execute a query but don't
> return it's results? The aim is to run a batch of queries to record the
> number of reads they make, without having to return data back to the
> client, which will take some time.
The best way is probably to insert the data into a table. Of course,
that will incur the cost of writing to disc, but that is probably
cheaper than to return to the client. At least you will get more
consistent performance, since you would not depend on network performance.
But you need to make sure that the database you are insering data into
is big enough, so that you results does not get distorted by auto-grow.
It may be more convenient to use SELECT INTO, than a pre-created table,
but creating a table SELECT INTO is more expensive than CREATE TABLE
and may cause some hundreds of reads on its own.
Whatever, don't use a table variable, because this could affect the
query plan, since you cannot get parallelism when you insert into a
table variable.
--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

No comments:

Post a Comment