use AdventureWorks; go create table dbo.Boloney ( RecordID int identity(1, 1) primary key clustered, Other varchar(128) null); go declare @id int; declare @t table (id int); insert into dbo.Boloney (Other) select top 10 [name] from sys.objects; -- you are limited to only getting the last id select @id = scope_identity(); select @id id; -- this will give you the id list of all affected records insert into dbo.Boloney (Other) output inserted.RecordID into @t select top 10 'z' + [name] from sys.objects; select stuff(list.id, 1, 2, '') list from ( select ', ' + cast(id as varchar(10)) from @t for xml path('') ) list(id); go -- results: id ----------- 10 list -------------------------------------- 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
No one has followed this question yet.