instead of manually performing actions to all databases, why don't you perform them in one database and replicate to other DBs?create table myTable (rowid int identity(1,1), col1 int)godeclare @vSQL nvarchar(200) ,@scope_identity intSet @vSQL = 'insert myTable (col1) values (1) set @ident = scope_Identity()'exec sp_executesql @vSQL, N'@ident int output', @ident = @scope_identity outputselect @scope_identitygodrop table myTablego
Be One with the OptimizerTGEDIT:Ident_current('myTable') works too but I suppose you could end up with an identity from a different, concurrent insert.