SQLServer Primary Keys - Mockstacks free tutorials For Beginners MOCKSTACKS HTML CSS JAVASCRIPT C++ C# Golang PHP PYTHON JAVA Kotlin RUST PERL VueJS Language: EN Deutsch Change Language X Loading languages... Close HTML Tutorial CSS Tutorial JAVASCRIPT Tutorial C++ Tutorial C# Tutorial Golang Tutorial PHP Tutorial PYTHON Tutorial JAVA Tutorial Kotlin Tutorial RUST Tutorial PERL Tutorial VueJS Tutorial SQLServer Tutorial . SQLServer Tutorial SQLServer Identifier SQLServer Data Types SQLServer NULL SQLServer Example Databases and Tables SQLServer SELECT SQLServer GROUP BY SQLServer ORDER BY SQLServer AND OR Operators SQLServer CASE SQLServer LIKE operator SQLServer IN clause SQLServer Filter results using WHERE and HAVING SQLServer SKIP TAKE Pagination SQLServer EXCEPT SQLServer EXPLAIN and DESCRIBE SQLServer EXISTS CLAUSE SQLServer JOIN SQLServer UPDATE SQLServer CREATE Database SQLServer CREATE TABLE SQLServer CREATE FUNCTION SQLServer TRY CATCH SQLServer UNION UNION ALL SQLServer ALTER TABLE SQLServer INSERT SQLServer MERGE SQLServer cross apply outer apply SQLServer DELETE SQLServer TRUNCATE SQLServer DROP Table SQLServer DROP or DELETE Database SQLServer Cascading Delete SQLServer GRANT and REVOKE SQLServer XML →SQLServer Primary Keys SQLServer Indexes SQLServer Row number SQLServer SQL Group By vs Distinct SQLServer Finding Duplicates on a Column Subset with Detail SQLServer String Functions SQLServer Functions Aggregate SQLServer Functions Scalar Single Row SQLServer Functions Analytic SQLServer Window Functions SQLServer Common Table Expressions SQLServer Views SQLServer Materialized Views SQLServer Comments SQLServer Foreign Keys SQLServer Sequence SQLServer Subqueries SQLServer Execution blocks SQLServer Stored Procedures SQLServer Triggers SQLServer Transactions SQLServer Table Design SQLServer Synonyms SQLServer Information Schema SQLServer Order of Execution SQLServer Clean Code in SQL SQLServer SQL Injection Show Topics Guides & Tutorials > SQLServer Primary Keys Previsous next SQLServer Primary Keys Creating a Primary Key CREATE TABLE Employees (  Id int NOT NULL,  PRIMARY KEY (Id),  ... ); This will create the Employees table with 'Id' as its primary key. The primary key can be used to uniquely identify the rows of a table. Only one primary key is allowed per table. A key can also be composed by one or more fields, so called composite key, with the following syntax: CREATE TABLE EMPLOYEE (  e1_id INT,  e2_id INT,  PRIMARY KEY (e1_id, e2_id) ) Conclusion In this page (written and validated by A. Gawali) you learned about SQLServer Primary Keys . What's Next? If you are interested in completing SQLServer tutorial, your next topic will be learning about: SQLServer Indexes. Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com. Share On: Twitter Facebook Linkedin Reddit Email Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.