36.UPDATE CASCADE in SQL Server

Published: 18 April 2022
on channel: Vasanth R
1,471
7

In this video, we will see about UPDATE CASCADE rules in SQL Server

Script
CREATE TABLE Countries1
(CountryID INT PRIMARY KEY,
CountryName VARCHAR(50),
CountryCode VARCHAR(3))

CREATE TABLE States1
(StateID INT PRIMARY KEY,
StateName VARCHAR(50),
StateCode VARCHAR(3),
CountryID INT)


ALTER TABLE [dbo].[States1] WITH CHECK ADD CONSTRAINT [FK_States_Countries1] FOREIGN KEY([CountryID])
REFERENCES [dbo].[Countries1] ([CountryID])
ON UPDATE CASCADE
GO

INSERT INTO Countries1 VALUES (1,'United States','USA')
INSERT INTO Countries1 VALUES (2,'United Kingdom','UK')
INSERT INTO Countries1 VALUES (3,'INDIA','IN')

INSERT INTO States1 VALUES (1,'Texas','TX',1)
INSERT INTO States1 VALUES (2,'Arizona','AZ',1)
INSERT INTO States1 VALUES (3,'Edinburg','En',2)
INSERT INTO States1 VALUES (4,'London','En',2)
INSERT INTO States1 VALUES (5,'Tamil Nadu','TN',3)
INSERT INTO States1 VALUES (6,'Delhi','DL',3)

update Countries1 set CountryID=4 where CountryID=3


On this page of the site you can watch the video online 36.UPDATE CASCADE in SQL Server with a duration of hours minute second in good quality, which was uploaded by the user Vasanth R 18 April 2022, share the link with friends and acquaintances, this video has already been watched 1,471 times on youtube and it was liked by 7 viewers. Enjoy your viewing!