Friday, November 26, 2021

How to create foreign key in SQL server

 >First create two tables Customers and Employee tables

>Customer table with Primary key(ID)(screenshot below)


>Employee table with Foreign key as (customer ID)(Screenshot below)

>Right Click on customer ID(screenshot below)

>Click on Add if key is not added, than click on "Tables and columns specifications){screenshot below}


>Select the primary key table (customer table) and foreign key table (employee table){screenshot below}


reference :- https://www.mssqltips.com/sqlservertip/4790/how-to-create-a-sql-server-foreign-key/

No comments:

Post a Comment