How To Update Primary Key Value In Sql
This browser is no longer supported.
Upgrade to Microsoft Border to take advantage of the latest features, security updates, and technical support.
Alter Principal Keys
Applies to: SQL Server 2016 (13.x) and subsequently
Azure SQL Database
Azure SQL Managed Case
You can alter a primary key in SQL Server by using SQL Server Management Studio or Transact-SQL. You lot can change the primary key of a table by changing the column social club, index name, amassed option, or fill factor.
In This Topic
-
Before you begin:
Security
-
To modify a primary key, using:
SQL Server Management Studio
Transact-SQL
Before You Brainstorm
Security
Permissions
Requires Change permission on the tabular array.
Using SQL Server Management Studio
To modify a primary key
-
Open the Tabular array Designer for the table whose principal key you desire to modify, right-click in the Tabular array Designer, and choose Indexes/Keys from the shortcut card.
-
In the Indexes/Keys dialog box, select the primary key index from the Selected Primary/Unique Key or Index listing.
-
Complete an action from the following table:
To Follow these steps Rename the master key Type a new name in the Name box. Make sure that your new name does not duplicate a proper name in the Selected Primary/Unique Key or Index listing. Set the clustered pick To create a clustered alphabetize for the primary primal, select Create every bit CLUSTERED, and select the option from the drop-downwards list box. Only 1 amassed index tin be per table. If this option is not available for your alphabetize, you must first clear this setting on the existing clustered index. If this option is non selected, a unique nonclustered index is created.
Define a fill factor Aggrandize the Make full Specification category and type an integer from 0 to 100 in the Fill factor box. For more information nigh fill factors and their uses, come across Specify Fill Gene for an Index. Alter the column guild Select Columns, and and then click the ellipses (...) to the correct of the property. In the Index Columns dialog box, remove the columns from the principal key. And then add the columns back in the order you desire. To remove a column from the key, simply remove the column name from the Column name list. -
On the File card, click Save table name.
Using Transact-SQL
To modify a primary key
To modify a PRIMARY Primal constraint using Transact-SQL, you must first delete the existing PRIMARY Fundamental constraint and then re-create it with the new definition. For more than information, meet Delete Primary Keys and Create Main Keys.
Feedback
Submit and view feedback for
Source: https://docs.microsoft.com/en-us/sql/relational-databases/tables/modify-primary-keys
Posted by: hillwhattudess.blogspot.com
0 Response to "How To Update Primary Key Value In Sql"
Post a Comment