{"id":296,"date":"2018-06-17T21:33:53","date_gmt":"2018-06-17T21:33:53","guid":{"rendered":"http:\/\/dbtut.com\/?p=296"},"modified":"2020-01-10T08:47:39","modified_gmt":"2020-01-10T08:47:39","slug":"what-is-unique-constraint","status":"publish","type":"post","link":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/","title":{"rendered":"What is Unique Constraint in SQL Server"},"content":{"rendered":"<h2>What is Unique Constraint in SQL Server?<\/h2>\n<p><span style=\"font-size: 1.125rem; font-family: var(--text-font);\">The Unique Constraint guarantees the uniqueness of the colum or column on the table. It can be created on one or more columns in the table.<\/span><\/p>\n<p>For example, suppose that you have a table with an ID column and a CountryName column.<\/p>\n<p>If you create a Unique Constraint on the ID column, you ensure that the ID value will be unique.<\/p>\n<p>So, the same ID can not inserted to the table.<\/p>\n<p>First, create a table with the help of the following script.<\/p>\n<pre class=\"lang:default decode:true \">CREATE TABLE [dbo].[Country](\n[ID] [int] NULL,\n[CountryName] [varchar](250) NULL)\nON [PRIMARY]<\/pre>\n<p>I will also add a record to the table with the following script.<\/p>\n<pre class=\"lang:default decode:true \">INSERT INTO [dbo].[Country]([ID],[CountryName]) VALUES (1,'England')<\/pre>\n<h3>Create Unique Constraint<\/h3>\n<p>To create our Unique Constraint, we use the following script.<\/p>\n<pre class=\"lang:default decode:true \">USE [Test]\u00a0\nGO\u00a0\nALTER TABLE [dbo].[Country] ADD CONSTRAINT ConstraintName UNIQUE(ID);\u00a0\u00a0\nGO<\/pre>\n<p>Now, the same value can not be inserted more than once for the ID column. The ID value is 1 in our previous record.<\/p>\n<p>Let&#8217;s try to make an insert using the same ID value as below. It will give an error as below.<\/p>\n<pre class=\"lang:default decode:true \">INSERT INTO [dbo].[Country]([ID],[CountryName]) VALUES (1,'Turkey')<\/pre>\n<p><span style=\"color: #ff0000;\"><em>Violation of UNIQUE KEY constraint &#8216;ConstraintName&#8217;. Cannot insert duplicate key in object &#8216;dbo.Country&#8217;. The duplicate key value is (1).<\/em><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14713 aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-39.png\" alt=\"\" width=\"763\" height=\"190\" \/><\/p>\n<h3>Does unique constraint allow null values in SQL Server?<\/h3>\n<p>Yes, we can insert one null value if there is unique constraint on the column. If we try to insert second null value to the column which has unique constraint, we receive the below error.<\/p>\n<pre class=\"lang:default decode:true \">INSERT INTO [dbo].[Country]([ID],[CountryName]) VALUES (null,'Turkey')\nINSERT INTO [dbo].[Country]([ID],[CountryName]) VALUES (null,'Germany')<\/pre>\n<p><span style=\"color: #ff0000;\"><em>Msg 2627, Level 14, State 1, Line 1 <\/em><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><em>Violation of UNIQUE KEY constraint &#8216;ConstraintName&#8217;. <\/em><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><em>Cannot insert duplicate key in object &#8216;dbo.Country&#8217;. The duplicate key value is (&lt;NULL&gt;). <\/em><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><em>The statement has been terminated.<\/em><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14715 aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-40.png\" alt=\"\" width=\"761\" height=\"190\" \/><\/p>\n<h3>DROP Unique Constraint<\/h3>\n<p>You can drop unique constraint as follows.<\/p>\n<pre class=\"lang:default decode:true\">USE [Test]\nGO\nALTER TABLE [dbo].[Country] DROP CONSTRAINT [ConstraintName]\nGO<\/pre>\n<p>If you want to learn more about Primary Key and Foreign Key and relationship between them, you may want to read the article &#8220;<a href=\"http:\/\/dbtut.com\/index.php\/2018\/06\/14\/what-is-primary-key-and-foreign-key\/\" target=\"_blank\" rel=\"noopener noreferrer\">What is Primary Key and Foreign Key<\/a>&#8220;,<\/p>\n<p>You can learn the differences between Primary Key and Unique Constraint by reading the article &#8220;<a href=\"http:\/\/dbtut.com\/index.php\/2018\/06\/16\/differences-between-primary-key-and-unique-constraint\/\" target=\"_blank\" rel=\"noopener noreferrer\">Differences Between Primary Key and Unique Constaint<\/a>&#8220;.<\/p>\n\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_296\" class=\"pvc_stats all  \" data-element-id=\"296\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>What is Unique Constraint in SQL Server? The Unique Constraint guarantees the uniqueness of the colum or column on the table. It can be created on one or more columns in the table. For example, suppose that you have a table with an ID column and a CountryName column. If you create a Unique Constraint &hellip;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_296\" class=\"pvc_stats all  \" data-element-id=\"296\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":14720,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[3],"tags":[7722,328,329,7706,7719,7725,7718,7717,7720,325,7707,7727,7715,7723,7728,7710,7724,7721,7714,7726,7704,7703,7705,7702,7712,192,7700,7701,326,324,7699,7713,7709,7711,327,7716],"class_list":["post-296","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-mssql","tag-a-guide-to-unique-constraints","tag-add-constraint-constraintname-unique","tag-add-constraint-xx-unique","tag-alter-table-add-constraint","tag-can-a-unique-column-have-multiple-null-values","tag-can-the-unique-key-be-null","tag-can-we-have-two-null-values-in-unique-key","tag-can-we-insert-multiple-null-values-for-unique-key","tag-can-we-insert-null-values-in-unique-column","tag-cannot-insert-duplicate-key-in-object","tag-create-unique-constraints","tag-delete-unique-constraints","tag-does-unique-allow-null-values","tag-drop-unique-constraint","tag-how-can-we-drop-unique-constraint","tag-how-do-i-add-a-unique-constraint-to-an-existing-column-in-sql-server","tag-how-do-you-create-a-unique-constraint-in-sql","tag-how-do-you-drop-a-unique-constraint-in-sql","tag-how-many-null-values-are-allowed-in-unique-key","tag-how-to-drop-a-unique-constraint","tag-ms-sql-server-alter-table-add-unique-constraint","tag-sql-management-studio-unique-column","tag-sql-server-add-constraint-unique","tag-sql-server-unique-constraint","tag-the-duplicate-key-value-is-null","tag-unique-constraint","tag-unique-constraint-sql-server","tag-unique-constraint-sql-server-multiple-columns","tag-uniqueness","tag-violation-of-unique-key-constraint","tag-violation-of-unique-key-constraint-cannot-insert-duplicate-key-in-object","tag-what-do-you-understand-by-unique-constraint","tag-what-is-a-unique-constraint-in-sql-server","tag-what-is-the-function-of-the-unique-constraint","tag-what-is-unique-constraint","tag-what-is-unique-in-database"],"aioseo_notices":[],"a3_pvc":{"activated":true,"total_views":171,"today_views":0},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is Unique Constraint in SQL Server - Database Tutorials<\/title>\n<meta name=\"description\" content=\"What is Unique Constraint in SQL Server\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Unique Constraint in SQL Server - Database Tutorials\" \/>\n<meta property=\"og:description\" content=\"What is Unique Constraint in SQL Server\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/\" \/>\n<meta property=\"og:site_name\" content=\"Database Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-17T21:33:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-01-10T08:47:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-41.png\" \/>\n\t<meta property=\"og:image:width\" content=\"506\" \/>\n\t<meta property=\"og:image:height\" content=\"324\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"dbtut\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"dbtut\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/\"},\"author\":{\"name\":\"dbtut\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408\"},\"headline\":\"What is Unique Constraint in SQL Server\",\"datePublished\":\"2018-06-17T21:33:53+00:00\",\"dateModified\":\"2020-01-10T08:47:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/\"},\"wordCount\":324,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-41.png\",\"keywords\":[\"A Guide to UNIQUE Constraints\",\"ADD CONSTRAINT ConstraintName UNIQUE\",\"ADD CONSTRAINT xx UNIQUE\",\"alter table add constraint\",\"Can a unique column have multiple NULL values?\",\"Can the unique key be null?\",\"Can we have two NULL values in unique key?\",\"Can we insert multiple NULL values for unique key?\",\"Can we insert null values in unique column?\",\"Cannot insert duplicate key in object\",\"Create Unique Constraints\",\"Delete Unique Constraints\",\"Does unique allow null values?\",\"drop unique constraint\",\"How can we drop UNIQUE constraint\",\"How do I add a unique constraint to an existing column in SQL Server?\",\"How do you create a unique constraint in SQL?\",\"How do you drop a unique constraint in SQL?\",\"How many null values are allowed in unique key?\",\"How to drop a unique constraint\",\"ms sql server alter table add unique constraint\",\"sql management studio unique column\",\"sql server add constraint unique\",\"sql server unique constraint\",\"The duplicate key value is (&lt;NULL&gt;).\",\"unique constraint\",\"unique constraint sql server\",\"unique constraint sql server multiple columns\",\"uniqueness\",\"Violation of UNIQUE KEY constraint\",\"Violation of UNIQUE KEY constraint. Cannot insert duplicate key in object.\",\"What do you understand by unique constraint?\",\"What is a unique constraint in SQL Server?\",\"What is the function of the unique constraint?\",\"what is unique constraint\",\"What is unique in database?\"],\"articleSection\":[\"MSSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/\",\"url\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/\",\"name\":\"What is Unique Constraint in SQL Server - Database Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-41.png\",\"datePublished\":\"2018-06-17T21:33:53+00:00\",\"dateModified\":\"2020-01-10T08:47:39+00:00\",\"description\":\"What is Unique Constraint in SQL Server\",\"breadcrumb\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#primaryimage\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-41.png\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-41.png\",\"width\":506,\"height\":324},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dbtut.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is Unique Constraint in SQL Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dbtut.com\/#website\",\"url\":\"https:\/\/dbtut.com\/\",\"name\":\"Database Tutorials\",\"description\":\"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux\",\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dbtut.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dbtut.com\/#organization\",\"name\":\"dbtut\",\"url\":\"https:\/\/dbtut.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"width\":223,\"height\":36,\"caption\":\"dbtut\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408\",\"name\":\"dbtut\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g\",\"caption\":\"dbtut\"},\"description\":\"We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.\",\"sameAs\":[\"http:\/\/NurullahCAKIR\"],\"url\":\"https:\/\/dbtut.com\/index.php\/author\/dbtut\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Unique Constraint in SQL Server - Database Tutorials","description":"What is Unique Constraint in SQL Server","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/","og_locale":"en_US","og_type":"article","og_title":"What is Unique Constraint in SQL Server - Database Tutorials","og_description":"What is Unique Constraint in SQL Server","og_url":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/","og_site_name":"Database Tutorials","article_published_time":"2018-06-17T21:33:53+00:00","article_modified_time":"2020-01-10T08:47:39+00:00","og_image":[{"width":506,"height":324,"url":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-41.png","type":"image\/png"}],"author":"dbtut","twitter_card":"summary_large_image","twitter_misc":{"Written by":"dbtut","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#article","isPartOf":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/"},"author":{"name":"dbtut","@id":"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408"},"headline":"What is Unique Constraint in SQL Server","datePublished":"2018-06-17T21:33:53+00:00","dateModified":"2020-01-10T08:47:39+00:00","mainEntityOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/"},"wordCount":324,"commentCount":0,"publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-41.png","keywords":["A Guide to UNIQUE Constraints","ADD CONSTRAINT ConstraintName UNIQUE","ADD CONSTRAINT xx UNIQUE","alter table add constraint","Can a unique column have multiple NULL values?","Can the unique key be null?","Can we have two NULL values in unique key?","Can we insert multiple NULL values for unique key?","Can we insert null values in unique column?","Cannot insert duplicate key in object","Create Unique Constraints","Delete Unique Constraints","Does unique allow null values?","drop unique constraint","How can we drop UNIQUE constraint","How do I add a unique constraint to an existing column in SQL Server?","How do you create a unique constraint in SQL?","How do you drop a unique constraint in SQL?","How many null values are allowed in unique key?","How to drop a unique constraint","ms sql server alter table add unique constraint","sql management studio unique column","sql server add constraint unique","sql server unique constraint","The duplicate key value is (&lt;NULL&gt;).","unique constraint","unique constraint sql server","unique constraint sql server multiple columns","uniqueness","Violation of UNIQUE KEY constraint","Violation of UNIQUE KEY constraint. Cannot insert duplicate key in object.","What do you understand by unique constraint?","What is a unique constraint in SQL Server?","What is the function of the unique constraint?","what is unique constraint","What is unique in database?"],"articleSection":["MSSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/","url":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/","name":"What is Unique Constraint in SQL Server - Database Tutorials","isPartOf":{"@id":"https:\/\/dbtut.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#primaryimage"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-41.png","datePublished":"2018-06-17T21:33:53+00:00","dateModified":"2020-01-10T08:47:39+00:00","description":"What is Unique Constraint in SQL Server","breadcrumb":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#primaryimage","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-41.png","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-41.png","width":506,"height":324},{"@type":"BreadcrumbList","@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/17\/what-is-unique-constraint\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dbtut.com\/"},{"@type":"ListItem","position":2,"name":"What is Unique Constraint in SQL Server"}]},{"@type":"WebSite","@id":"https:\/\/dbtut.com\/#website","url":"https:\/\/dbtut.com\/","name":"Database Tutorials","description":"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux","publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dbtut.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/dbtut.com\/#organization","name":"dbtut","url":"https:\/\/dbtut.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","width":223,"height":36,"caption":"dbtut"},"image":{"@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408","name":"dbtut","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g","caption":"dbtut"},"description":"We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.","sameAs":["http:\/\/NurullahCAKIR"],"url":"https:\/\/dbtut.com\/index.php\/author\/dbtut\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/comments?post=296"}],"version-history":[{"count":0,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/296\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media\/14720"}],"wp:attachment":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media?parent=296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/categories?post=296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/tags?post=296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}