set @ai_DupCount=0;
set @as_Sql = N'select @ai_DupCount=count(*) from ' + @as_TbName + ' where ' + @as_ColName + ' = ' + @as_ID;
execute sp_executesql @as_Sql,N'@ai_DupCount int output',@ai_DupCount output;
set @as_Sql='delete from ' + @as_TableNames + ' where ' + @as_PKName + ' = ' + @as_ID;
execute(@as_Sql);