I have a database that I want to use transactional replication on but several of the tables don't have primary keys - is there a quick query that I can run that will return a list of the tables without PK's?
Thanks in advance for the help!
Kevin
Use the OBJECTPROPERTY function (the TableHasPrimaryKey option). See SQL
Server Books Online for more information.
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"Kevin" <anonymous@.discussions.microsoft.com> wrote in message
news:398BB944-469B-4C1B-AD9C-0E3500909484@.microsoft.com...
I have a database that I want to use transactional replication on but
several of the tables don't have primary keys - is there a quick query that
I can run that will return a list of the tables without PK's?
Thanks in advance for the help!
Kevin
|||Kevin,
assuming all objects are owned by dbo, some variation on the theme of:
select * from information_schema.tables
where table_type = 'BASE TABLE'
and table_name not in (select table_name from
information_schema.table_constraints where
constraint_type='Primary Key')
should do you.
Regards,
Paul Ibison
|||Thanks Paul - that worked great! I was close but the subselect was killing me!
Showing posts with label replication. Show all posts
Showing posts with label replication. Show all posts
Friday, March 23, 2012
query for tables without PK
Query for Replication Status
Hi,
We have 50 databases in Merge Replication.
We want to know the replication status (replicating or failed) using query,
Any query is there to find out the status?
Please advise me.
Rgds,
Soura
Soura,
you could have a look at sp_MSenum_merge_subscriptions. It takes the last
value for a merge agent in MSmerge_history and looks at the runstatus value.
Alternatively, you could use my proc which works against job states directly
(http://www.replicationanswers.com/Do...unningJobs.txt). These
could be mapped to : -- 1 = Executing, 2 = Waiting For Thread, 3 = Between
Retries, 4 = Idle, 5 = Suspended, 6 = [obsolete], 7 =
PerformingCompletionActions.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
We have 50 databases in Merge Replication.
We want to know the replication status (replicating or failed) using query,
Any query is there to find out the status?
Please advise me.
Rgds,
Soura
Soura,
you could have a look at sp_MSenum_merge_subscriptions. It takes the last
value for a merge agent in MSmerge_history and looks at the runstatus value.
Alternatively, you could use my proc which works against job states directly
(http://www.replicationanswers.com/Do...unningJobs.txt). These
could be mapped to : -- 1 = Executing, 2 = Waiting For Thread, 3 = Between
Retries, 4 = Idle, 5 = Suspended, 6 = [obsolete], 7 =
PerformingCompletionActions.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
Subscribe to:
Posts (Atom)