Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

output behavior Expand / Collapse
Author
Message
Posted Thursday, May 07, 2009 12:04 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, March 06, 2014 11:38 AM
Points: 228, Visits: 102
/*
I'm had a question on the behavior of OUTPUT statement (I would assume this applies to DELETE myTblA OUTPUT INTO myTblB and INSERT myTblA OUTPUT INTO myTblB as well).

Below is my script:
*/
-- begin testing output statement

if object_id('tempdb.dbo.#tA','u') is not null drop table #tA
if object_id('tempdb.dbo.#tB','u') is not null drop table #tB

create table #tB
(
id int identity( 1, 1 )--,
-- f1 char(1)
)


select id = identity(int,5,1)
into #tA

--insert #tB (f1)
--select 'a'

select * from #tA

delete #tA
output deleted.id--, 'b'
into #tB (id)--, f1)

select * from #tA
select * from #tB

-- end testing output statement
/* begin questions
1. Does OUTPUT set identity_insert #tB on automatically for a table with Identity column?
*/ end questions
Post #712311
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse