Flowing Fount of Yak Knowledge
Posted - 12/07/2012 : 03:52:02
| Which way does the foreign key go?
I assume this is the master row and referenced by the other tables.
select t1.col, count(t2.col), count(t3.col), ...
left join t2 on t2.col = t1.col
left join t3 on t3.col = t1.col
--where t1.col = 'myval'
This will give a 0 for the table if it is not referenced.
Use the where clause if you want to check a specific row.
note: the referencing tables may not have an index on the column so this may table scan.
You can check the individual tables using an inner join rather than left join.
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.