You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can modify a check constraint in [!INCLUDE[ssCurrent](../../includes/sscurrent-md.md)] by using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] or [!INCLUDE[tsql](../../includes/tsql-md.md)] when you want to change the constraint expression or the options that enable or disable the constraint for specific conditions.
27
-
28
-
**In This Topic**
29
-
30
-
-**Before you begin:**
31
-
32
-
[Security](#Security)
33
-
34
-
-**To modify a check constraint using:**
35
-
36
-
[SQL Server Management Studio](#SSMSProcedure)
37
-
38
-
[Transact-SQL](#TsqlProcedure)
39
-
40
-
## <aname="BeforeYouBegin"></a> Before You Begin
41
-
42
-
### <aname="Security"></a> Security
43
-
44
-
#### <aname="Permissions"></a> Permissions
45
-
Requires ALTER permission on the table.
46
-
47
-
## <aname="SSMSProcedure"></a> Using SQL Server Management Studio
48
-
49
-
#### To modify a check constraint
50
-
51
-
1. In the **Object Explorer**, right-click the table containing the check constraint and select **Design**.
52
-
53
-
2. On the **Table Designer** menu, click **Check Constraints…**.
54
-
55
-
3. In the **Check Constraints** dialog box, under **Selected Check Constraint**, select the constraint you wish to edit.
56
-
57
-
4. Complete an action from the following table:
58
-
59
-
|To|Follow these steps|
60
-
|--------|------------------------|
61
-
|Edit the constraint expression|Type the new expression in the **Expression** field.|
62
-
|Rename the constraint|Type a new name in the **Name** field.|
63
-
|Apply the constraint to existing data|Select the **Check Existing Data on Creation or Enabling** option.|
64
-
|Disable the constraint when new data is added to the table or when existing data is updated in the table.|Clear the **Enforce Constraint for INSERTs and UPDATEs** option.|
65
-
|Disable the constraint when a replication agent inserts or updates data in your table.|Clear the **Enforce For Replication** option.|
66
-
67
-
> [!NOTE]
68
-
> Some databases have different functionality for check constraints.
69
-
70
-
5. Click **Close**.
71
-
72
-
6. On the **File** menu, click **Save***table name*.
73
-
74
-
## <aname="TsqlProcedure"></a> Using Transact-SQL
75
-
**To modify a check constraint**
76
-
77
-
To modify a `CHECK` constraint using [!INCLUDE[tsql](../../includes/tsql-md.md)], you must first delete the existing `CHECK` constraint and then re-create it with the new definition. For more information, see [Delete Check Constraints](../../relational-databases/tables/delete-check-constraints.md) and [Create Check Constraints](../../relational-databases/tables/create-check-constraints.md).
78
-
79
-
### <aname="TsqlExample"></a>
26
+
You can modify a check constraint in [!INCLUDE[ssCurrent](../../includes/sscurrent-md.md)] by using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] or [!INCLUDE[tsql](../../includes/tsql-md.md)] when you want to change the constraint expression or the options that enable or disable the constraint for specific conditions.
27
+
28
+
**In This Topic**
29
+
30
+
-**Before you begin:**
31
+
32
+
[Security](#Security)
33
+
34
+
-**To modify a check constraint using:**
35
+
36
+
[SQL Server Management Studio](#SSMSProcedure)
37
+
38
+
[Transact-SQL](#TsqlProcedure)
39
+
40
+
## <aname="BeforeYouBegin"></a> Before You Begin
41
+
42
+
### <aname="Security"></a> Security
43
+
44
+
#### <aname="Permissions"></a> Permissions
45
+
Requires ALTER permission on the table.
46
+
47
+
## <aname="SSMSProcedure"></a> Using SQL Server Management Studio
48
+
49
+
#### To modify a check constraint
50
+
51
+
1. In the **Object Explorer**, right-click the table containing the check constraint and select **Design**.
52
+
53
+
2. On the **Table Designer** menu, click **Check Constraints…**.
54
+
55
+
3. In the **Check Constraints** dialog box, under **Selected Check Constraint**, select the constraint you wish to edit.
56
+
57
+
4. Complete an action from the following table:
58
+
59
+
|To|Follow these steps|
60
+
|--------|------------------------|
61
+
|Edit the constraint expression|Type the new expression in the **Expression** field.|
62
+
|Rename the constraint|Type a new name in the **Name** field.|
63
+
|Apply the constraint to existing data|Select the **Check Existing Data on Creation or Enabling** option.|
64
+
|Disable the constraint when new data is added to the table or when existing data is updated in the table.|Clear the **Enforce Constraint for INSERTs and UPDATEs** option.|
65
+
|Disable the constraint when a replication agent inserts or updates data in your table.|Clear the **Enforce For Replication** option.|
66
+
67
+
> [!NOTE]
68
+
> Some databases have different functionality for check constraints.
69
+
70
+
5. Click **Close**.
71
+
72
+
6. On the **File** menu, click **Save***table name*.
73
+
74
+
## <aname="TsqlProcedure"></a> Using Transact-SQL
75
+
**To modify a check constraint**
76
+
77
+
To modify a `CHECK` constraint using [!INCLUDE[tsql](../../includes/tsql-md.md)], you must first delete the existing `CHECK` constraint and then re-create it with the new definition. For more information, see [Delete Check Constraints](../../relational-databases/tables/delete-check-constraints.md) and [Create Check Constraints](../../relational-databases/tables/create-check-constraints.md).
0 commit comments