Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit e6fc77a

Browse files
committed
Refresh foreign key properties article and address UUF 229348
1 parent ede10ab commit e6fc77a

2 files changed

Lines changed: 52 additions & 53 deletions

File tree

docs/includes/sscatviewperm-md.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
author: rwestMSFT
33
ms.author: randolphwest
4-
ms.date: 01/29/2024
4+
ms.date: 03/19/2024
55
ms.service: sql
66
ms.topic: include
77
---
8-
The visibility of the metadata in catalog views is limited to securables that a user either owns or on which the user has been granted some permission.
8+
The visibility of the metadata in catalog views is limited to securables that a user either owns, or on which the user was granted some permission.
Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,68 @@
11
---
22
title: "View Foreign Key Properties"
3-
description: "You can view the foreign key attributes of a relationship with SQL Server Management Studio or T-SQL queries."
3+
description: View the foreign key attributes of a relationship with SQL Server Management Studio or T-SQL queries.
44
author: WilliamDAssafMSFT
55
ms.author: wiassaf
6-
ms.date: "04/13/2022"
6+
ms.reviewer: randolphwest
7+
ms.date: 03/19/2024
78
ms.service: sql
89
ms.subservice: table-view-index
910
ms.topic: conceptual
1011
helpviewer_keywords:
1112
- "foreign keys [SQL Server], attributes"
1213
- "displaying foreign keys attributes"
1314
- "viewing foreign keys attributes"
14-
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current"
15+
monikerRange: ">=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current"
1516
---
1617
# View foreign key properties
18+
1719
[!INCLUDE [sqlserver2016-asdb-asdbmi-asa-pdw](../../includes/applies-to-version/sqlserver2016-asdb-asdbmi-asa-pdw.md)]
1820

19-
You can view the foreign key attributes of a relationship in [!INCLUDE[ssnoversion](../../includes/ssnoversion-md.md)] by using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] or [!INCLUDE[tsql](../../includes/tsql-md.md)].
20-
21-
### <a name="Permissions"></a> Permissions
22-
[!INCLUDE[ssCatViewPerm](../../includes/sscatviewperm-md.md)] For more information, see [Metadata Visibility Configuration](../../relational-databases/security/metadata-visibility-configuration.md).
23-
24-
## <a name="SSMSProcedure"></a> Using SQL Server Management Studio
25-
26-
#### To view the foreign key attributes of a relationship in a specific table
27-
28-
1. Open the Table Designer for the table containing the foreign key you want to view, right-click in the Table Designer, and choose **Relationships** from the shortcut menu.
29-
30-
2. In the **Foreign Key Relationships** dialog box, select the relationship with properties you want to view.
31-
32-
If the foreign key columns are related to a primary key, the primary key columns are identified in **Table Designer** by a primary key symbol in the row selector.
33-
34-
<a name="TsqlExample"></a>
35-
## <a name="TsqlProcedure"></a> Using Transact-SQL
36-
37-
#### To view the foreign key attributes of a relationship in a specific table
38-
39-
1. In **Object Explorer**, connect to an instance of [!INCLUDE[ssDE](../../includes/ssde-md.md)].
40-
41-
2. On the Standard bar, select **New Query**.
42-
43-
3. Copy and paste the following example into the query window and select **Execute**. The example returns all foreign keys and their properties for the table `HumanResources.Employee` in the sample database.
44-
45-
```sql
46-
USE AdventureWorks2022;
47-
GO
48-
SELECT
49-
f.name AS foreign_key_name
50-
,OBJECT_NAME(f.parent_object_id) AS table_name
51-
,COL_NAME(fc.parent_object_id, fc.parent_column_id) AS constraint_column_name
52-
,OBJECT_NAME (f.referenced_object_id) AS referenced_object
53-
,COL_NAME(fc.referenced_object_id, fc.referenced_column_id) AS referenced_column_name
54-
,f.is_disabled, f.is_not_trusted
55-
,f.delete_referential_action_desc
56-
,f.update_referential_action_desc
57-
FROM sys.foreign_keys AS f
58-
INNER JOIN sys.foreign_key_columns AS fc
59-
ON f.object_id = fc.constraint_object_id
60-
WHERE f.parent_object_id = OBJECT_ID('HumanResources.Employee');
61-
```
62-
63-
For more information, see [sys.foreign_keys &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-foreign-keys-transact-sql.md) and [sys.foreign_key_columns &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-foreign-key-columns-transact-sql.md).
64-
65-
## Next steps
21+
You can view the foreign key attributes of a relationship in [!INCLUDE [ssnoversion](../../includes/ssnoversion-md.md)] by using [!INCLUDE [ssManStudioFull](../../includes/ssmanstudiofull-md.md)] or [!INCLUDE [tsql](../../includes/tsql-md.md)].
22+
23+
### Permissions
24+
25+
[!INCLUDE [ssCatViewPerm](../../includes/sscatviewperm-md.md)] For more information, see [Metadata Visibility Configuration](../security/metadata-visibility-configuration.md).
26+
27+
## <a id="SSMSProcedure"></a> Use SQL Server Management Studio
28+
29+
1. Open the Table Designer for the table containing the foreign key you want to view, right-click in the Table Designer, and choose **Relationships** from the shortcut menu.
30+
31+
1. In the **Foreign Key Relationships** dialog box, select the relationship with properties you want to view.
32+
33+
If the foreign key columns are related to a primary key, the primary key columns are identified in **Table Designer** by a primary key symbol in the row selector.
34+
35+
## <a id="TsqlExample"></a> Use Transact-SQL
36+
37+
1. In **Object Explorer**, connect to an instance of [!INCLUDE [ssDE](../../includes/ssde-md.md)].
38+
39+
1. On the Standard bar, select **New Query**.
40+
41+
1. Copy and paste the following example into the query window and select **Execute**. The example returns all foreign keys and their properties for the table `HumanResources.Employee` in the sample database.
42+
43+
```sql
44+
USE AdventureWorks2022;
45+
GO
46+
47+
SELECT f.name AS foreign_key_name,
48+
OBJECT_NAME(f.parent_object_id) AS table_name,
49+
COL_NAME(fc.parent_object_id, fc.parent_column_id) AS constraint_column_name,
50+
OBJECT_NAME(f.referenced_object_id) AS referenced_object,
51+
COL_NAME(fc.referenced_object_id, fc.referenced_column_id) AS referenced_column_name,
52+
f.is_disabled,
53+
f.is_not_trusted,
54+
f.delete_referential_action_desc,
55+
f.update_referential_action_desc
56+
FROM sys.foreign_keys AS f
57+
INNER JOIN sys.foreign_key_columns AS fc
58+
ON f.object_id = fc.constraint_object_id
59+
WHERE f.parent_object_id = OBJECT_ID('HumanResources.Employee');
60+
```
61+
62+
For more information, see [sys.foreign_keys](../system-catalog-views/sys-foreign-keys-transact-sql.md) and [sys.foreign_key_columns](../system-catalog-views/sys-foreign-key-columns-transact-sql.md).
63+
64+
## Related content
6665

6766
- [ALTER TABLE Statement](../../odbc/microsoft/alter-table-statement.md)
6867
- [Disable foreign key constraints for replication](disable-foreign-key-constraints-for-replication.md)
69-
- [Disable Foreign Key Constraints with INSERT and UPDATE Statements](disable-foreign-key-constraints-with-insert-and-update-statements.md)
68+
- [Disable foreign key constraints with INSERT and UPDATE statements](disable-foreign-key-constraints-with-insert-and-update-statements.md)

0 commit comments

Comments
 (0)