Re: nocount
From: Uri Dimant (urid_at_iscar.co.il)
Date: 10/04/04
- Next message: Jacco Schalkwijk: "Re: Duplicate Entries Help"
- Previous message: Oskar: "Re: nocount"
- In reply to: Hugo Kornelis: "Re: nocount"
- Next in thread: Hugo Kornelis: "Re: nocount"
- Reply: Hugo Kornelis: "Re: nocount"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 4 Oct 2004 13:35:42 +0200
Hi,Hugo
> declare @num int
> select @num = count(*)
What was a purpose to declare this variable and not using it?
If if does affect the perfomance (some big logic inside the trigger) so I
would not use trigger at all.
But now I have just finished read this article in the BOL and I will have
to review my triggers again.
"Hugo Kornelis" <hugo@pe_NO_rFact.in_SPAM_fo> wrote in message
news:2jb2m0dpt5k6g9vjr8c0hkmftaf2amhumd@4ax.com...
> On Mon, 4 Oct 2004 12:41:56 +0200, Uri Dimant wrote:
>
> >Oscar
> >When SET NOCOUNT ON SQL Server does not inform users about rows were
> >affected.
> >It is good practice to set it up at the beginning of stored procedures
but i
> >have not seen this command within triggers. It's meaningless.
>
> Hi Uri,
>
> This is not correct. Run the following code with and wothout the set
> nocount on statement in the trigger to see the difference.
>
> set nocount off
> go
> create table test (a int not null)
> go
> create table test2 (now datetime not null primary key default(getdate()),
> num int not null)
> go
> create trigger testtrig on test after insert
> as
> --set nocount on
> declare @num int
> select @num = count(*)
> from inserted
> insert into test2(num)
> select @num
> update test set a = a
> go
> insert test
> select 1 union all select 2
> go
> select * from test2
> go
> drop table test2, test
> go
>
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Jacco Schalkwijk: "Re: Duplicate Entries Help"
- Previous message: Oskar: "Re: nocount"
- In reply to: Hugo Kornelis: "Re: nocount"
- Next in thread: Hugo Kornelis: "Re: nocount"
- Reply: Hugo Kornelis: "Re: nocount"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|