July 23, 2013 at 1:52 pm
Thanks for the question Pramod. I had never considered how output would work with triggers.
July 24, 2013 at 12:47 am
Nice...
July 24, 2013 at 12:49 am
Danny Ocean (7/22/2013)
Good question. I learn something new. 🙂
Yes...+1
July 24, 2013 at 1:08 am
Hugo Kornelis (7/23/2013)
...
In other words - if the statement causes a trigger to fire, it should have either no OUTPUT clause or an OUTPUT clause with an INTO keyword. Using the OUTPUT clause without INTO (so that the results of the OUTPUT specification go to the client) is not allowed when a trigger fires.
The question is WHY?
Technically, I do not see the connection or the hindrance of TRIGGER -> OUTPUT -> INTO.
July 24, 2013 at 1:35 am
Carlo Romagnano (7/24/2013)
Hugo Kornelis (7/23/2013)
...
In other words - if the statement causes a trigger to fire, it should have either no OUTPUT clause or an OUTPUT clause with an INTO keyword. Using the OUTPUT clause without INTO (so that the results of the OUTPUT specification go to the client) is not allowed when a trigger fires.
The question is WHY?
Technically, I do not see the connection or the hindrance of TRIGGER -> OUTPUT -> INTO.
<speculation>
OUTPUT without INTO sends data to the client.
A trigger might also send output to the client.
Maybe there were some test cases where the two outputs somehow interfered, and the team decided that fixing it would take too much resources???
</speculation>
July 24, 2013 at 5:58 am
Good and tough question 🙂
July 24, 2013 at 11:14 am
This was an interesting one - thanks, Pramod!
July 25, 2013 at 2:57 pm
Lokesh Vij (7/22/2013)
Good Question Pramod. But explanation could have been refined.
+2
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
August 1, 2013 at 8:21 am
Sorry, seems something not clear in this question, in the Question (select 4) what it means
i am choosing 2 3 5 it say i am wrong
if object_id('test2') is not null
drop table test2
if object_id('test1') is not null
drop table test1
create table test1 (a int not null primary key);
create table test2 (b int,a int )
GO
--statement 1
insert into test1
output inserted.a
select 1
GO
--statement 2
create trigger trig_test1
on test1 after insert
as
select 2
GO
--statement 3
insert into test1
select 3
GO
--statement 4
insert into test1
output inserted.a
select 4
GO
--statement 5
declare @temp as table (b int)
insert into test1
output inserted.a
into @temp
select 5
select * from @temp
GO
So what is statement 1
Every rule in a world of bits and bytes, can be bend or eventually be broken
MyBlog About Common dialog control
A Visualizer for viewing SqlCommand object script [/url]
August 2, 2013 at 1:44 am
Good QOTD. And some good clarification by Hugo (as always). 🙂
Viewing 10 posts - 16 through 24 (of 24 total)
You must be logged in to reply to this topic. Login to reply