Wednesday, March 7, 2012

dont show select results

hi
is it possible in a query dont show the result rows'
i wanna write
select *
from table
set @.num=@.@.rowcount
and i dont wanna see all the rows affected
thanks
CarloHow about
SELECT @.num = COUNT(*) FROM table
"Carlo" <carletto.m@.NOSPAMgmail.com> wrote in message
news:%23kaDMPwrFHA.1788@.tk2msftngp13.phx.gbl...
> hi
> is it possible in a query dont show the result rows'
> i wanna write
> select *
> from table
> set @.num=@.@.rowcount
> and i dont wanna see all the rows affected
> thanks
> Carlo
>|||SET @.num =
(SELECT COUNT(*)
FROM table)
Note that @.@.ROWCOUNT will now be 1regardless of the value returned in
@.num.
David Portas
SQL Server MVP
--|||Carlo,
What for is @.num?. You can do the following:
select @.num = count(*) from t1 where ...
...
or
if exists(select * from t1 where ...)
..
AMB
"Carlo" wrote:

> hi
> is it possible in a query dont show the result rows'
> i wanna write
> select *
> from table
> set @.num=@.@.rowcount
> and i dont wanna see all the rows affected
> thanks
> Carlo
>
>|||Carlo wrote:
> hi
> is it possible in a query dont show the result rows'
> i wanna write
> select *
> from table
> set @.num=@.@.rowcount
> and i dont wanna see all the rows affected
> thanks
> Carlo
Row Affected shows up when you have not set SET NOCOUNT ON. You've
already received the answer if what you wanted was to not see the rows
themselves, but when reading your post, it's not clear what you want.
If you want to see all the rows, then define the select statement with
only the columns you need. Assuming you're fetching them on the client,
you can count the rows there.
If all you need is the rowcount for the select statement, then read the
other posts about assigning the count to a local variable.
You should always have SET NOCOUNT ON as the first statement of each
stored procedure and as the first SQL call from an application that uses
embedded SQL. That will suppress the "x Row(s) Affected" message.
David Gugick
Quest Software
www.imceda.com
www.quest.com|||thanks
another stupid question:
can i dont write the message like :
(7 row(s) affected)
'?
thanks
carlo
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> ha scritto nel
messaggio news:ugcV$SwrFHA.1204@.TK2MSFTNGP15.phx.gbl...
> How about
> SELECT @.num = COUNT(*) FROM table
>
> "Carlo" <carletto.m@.NOSPAMgmail.com> wrote in message
> news:%23kaDMPwrFHA.1788@.tk2msftngp13.phx.gbl...
>|||SET NOCOUNT ON

No comments:

Post a Comment