Search This Blog

Return a CSV of the affected records without using OUTPUT

set
nocount
on

declare @Tab table ( id int
identity
, i int
,j date
)

insert
into @Tab select 1,
'2008-01-01'

insert
into @Tab select 1,
'2008-01-02'

insert
into @Tab select 1,
'2008-01-03'

insert
into @Tab select 2,
'2008-01-04'

insert
into @Tab select 2,
'2008-01-15'

insert
into @Tab select 1,
'2008-01-21'


 

declare @res varchar(max)


 

update @Tab

set @res =
COALESCE(@res+',',
'')+CAST(id as
varchar
),

j =
SYSDATETIME()

where i = 1


 

select
*
from @Tab

select @res


 

1 comment:

daspeac said...

it seems you have never heard about the repair database script mssql 2005