Update mssql.md
This commit is contained in:
parent
534d6e1d8a
commit
a0fe20626b
1 changed files with 5 additions and 6 deletions
11
SQL/mssql.md
11
SQL/mssql.md
|
|
@ -1,11 +1,10 @@
|
||||||
--- query foreign keys on all tables (local/remote) matching a pattern
|
--- query foreign keys on all tables (local/remote) matching a pattern
|
||||||
|
|
||||||
```SQL
|
```SQL
|
||||||
SELECT
|
SELECT OBJECT_NAME(f.parent_object_id) as tablename,
|
||||||
OBJECT_NAME(f.parent_object_id) as tablename,
|
|
||||||
OBJECT_NAME(f.referenced_object_id) as remote_tablename
|
OBJECT_NAME(f.referenced_object_id) as remote_tablename
|
||||||
FROM sys.foreign_keys as f
|
FROM sys.foreign_keys as f
|
||||||
WHERE OBJECT_NAME(f.referenced_object_id) not like 'SWE_%'
|
WHERE OBJECT_NAME(f.referenced_object_id) not like 'SWE_%'
|
||||||
AND OBJECT_NAME(f.parent_object_id) like 'SWE_%'
|
AND OBJECT_NAME(f.parent_object_id) like 'SWE_%'
|
||||||
order by tablename;
|
ORDER BY tablename;
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue