In this video, we will see about DELETE CASCADE rules in SQL Server
Script :
CREATE TABLE Countries
(CountryID INT PRIMARY KEY,
CountryName VARCHAR(50),
CountryCode VARCHAR(3))
CREATE TABLE States
(StateID INT PRIMARY KEY,
StateName VARCHAR(50),
StateCode VARCHAR(3),
CountryID INT)
ALTER TABLE [dbo].[States] WITH CHECK ADD CONSTRAINT [FK_States_Countries] FOREIGN KEY([CountryID])
REFERENCES [dbo].[Countries] ([CountryID])
ON DELETE CASCADE
GO
INSERT INTO Countries VALUES (1,'United States','USA')
INSERT INTO Countries VALUES (2,'United Kingdom','UK')
INSERT INTO Countries VALUES (3,'India','IN')
INSERT INTO States VALUES (1,'Texas','TX',1)
INSERT INTO States VALUES (2,'Arizona','AZ',1)
INSERT INTO States VALUES (3,'Edinburg','En',2)
INSERT INTO States VALUES (4,'London','Lo',2)
INSERT INTO States VALUES (5,'Tamil Nadu','TN',3)
INSERT INTO States VALUES (6,'Delhi','DL',3)
Delete from Countries where CountryID=1
select * from Countries
select * from states
In questa pagina del sito puoi guardare il video online 35.DELETE CASCADE In SQL Server della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Vasanth R 11 aprile 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 3,180 volte e gli è piaciuto 21 spettatori. Buona visione!