select distinct [Tablename], [ColumnName], [Validator], [Expression], [Message], [Attribute] into #Tmp from tFieldValidator
--SELECT * from #Tmp
DELETE tFieldValidator
Declare @id int
exec @id=pNextID 'tFieldValidator'
INSERT into tFieldValidator (id,[Tablename], [ColumnName], [Validator], [Expression], [Message], [Attribute] ) SELECT @id+row_number() over(order by [Tablename], [ColumnName], [Validator], [Expression], [Message], [Attribute]),[Tablename], [ColumnName], [Validator], [Expression], [Message], [Attribute] from #Tmp
drop table #Tmp
--SELECT * from #Tmp
DELETE tFieldValidator
Declare @id int
exec @id=pNextID 'tFieldValidator'
INSERT into tFieldValidator (id,[Tablename], [ColumnName], [Validator], [Expression], [Message], [Attribute] ) SELECT @id+row_number() over(order by [Tablename], [ColumnName], [Validator], [Expression], [Message], [Attribute]),[Tablename], [ColumnName], [Validator], [Expression], [Message], [Attribute] from #Tmp
drop table #Tmp