Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 AutoNumber PKey fields

Author  Topic 

stackerman
Starting Member

1 Post

Posted - 2014-08-20 : 14:38:34
Ok - so admittedly I am no DBA - just a SysAdmin/Security guy. I do know enough to realize that we had issues recently with SQL Replication that were due to AutoNumber fields being used as the PKEY and inconsistencies in the relationships afterwards due to it.

I know that we COULD choose the not for repl option on these OR create some type of GUID field, etc (that will be up to the dev guys). For now I am curious though if there is a way to assess how large a task this will be? What I really think I am looking for is a query that will audit/list any tables that have an AUTONUMBER field used as the PKEY...

Is there a simple query for this?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-08-20 : 14:48:47
Here you go:
select object_name(object_id) as TableName, name as ColumnName
from sys.columns
where is_identity = 1
order by 1

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-08-20 : 14:49:57
As a DBA, I would recommend using the NOT FOR REPLICATION option instead of a GUID column. There are challenges with GUIDs. Too big of a topic here, but it's something that needs to be researched and designed properly.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -