Re: script to find all parent records that have references in at least one table.
- From: Inna <mednyk@xxxxxxxxxxx>
- Date: Wed, 14 Jan 2009 15:27:03 -0800 (PST)
On Jan 13, 5:31 pm, Erland Sommarskog <esq...@xxxxxxxxxxxxx> wrote:
Inna (med...@xxxxxxxxxxx) writes:
I have multiple databases for the same application; each database is
for different project.
They have exactly the same structure. We decided to move/unify all
corporate tables, like Country, Currency, and Language etc in the
separate database. The problem: since the data is entered manually
from applications we have the same records in different databases, but
spelled differently, even different names (French, English ...) or
with the different primary keys. All databases are relatively old, so
a good half of the records we want to move most likely has references
within its database. I need a list of all records by table that has
references within database, because for those we will need the
separate treatment. Meaning all the clients will have to approve name
or maybe we can disable some and move the references in archives. For
those that are not referenced we will delete and recreate in corporate
database with proper name. It’s a very slow process, we will be doing
it table by table, but for all databases in one shot. That is why I
would need something more or less generic, to be able to pass a table
name to SP and find all those records in the table that have
references and supply list to a clients.
I'm sorry, but I forgot to ask: which version of SQL Server are you on?
This affects the possible solutions a bit.
I'm not entirely convinced that it's a good idea to move data out to
a centralized database. Keep in mind that if you do this, you cannot
implement referential integrity with constraints, but will have to
resort to triggers. You are using constraints to enforce foreign keys,
aren't you? If not, then your task will be even more difficult.
Possibly you could have a centralised database where this corporate
data is maintained, and which you then replicate to the customer
databases. Then you could maintain data in one place, but still keep
referential integrity.
--
Erland Sommarskog, SQL Server MVP, esq...@xxxxxxxxxxxxx
Links for SQL Server Books Online:
SQL 2008:http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005:http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000:http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx- Hide quoted text -
- Show quoted text -
Hello,
It's exactly what I would like to do, to replicate but for that I
will need to update all referenced IDs, in which situation that SP
would be handy again. I can reuse the code
So we are still using 2000 for that application. All my tables are
using foreign keys, not triggers.
Thank you
.
- Follow-Ups:
- Re: script to find all parent records that have references in at least one table.
- From: Erland Sommarskog
- Re: script to find all parent records that have references in at least one table.
- References:
- script to find all parent records that have references in at least one table.
- From: Inna
- Re: script to find all parent records that have references in at least one table.
- From: Erland Sommarskog
- Re: script to find all parent records that have references in at least one table.
- From: Inna
- Re: script to find all parent records that have references in at least one table.
- From: Erland Sommarskog
- script to find all parent records that have references in at least one table.
- Prev by Date: Re: profiler shows repeated execution of statements
- Next by Date: Re: script to find all parent records that have references in at least one table.
- Previous by thread: Re: script to find all parent records that have references in at least one table.
- Next by thread: Re: script to find all parent records that have references in at least one table.
- Index(es):
Relevant Pages
|
Loading