How to add casade delete on existing table

CREATE TABLE Books (
   BookID INT NOT NULL PRIMARY KEY,
   AuthorID INT NOT NULL,
   BookName VARCHAR(100) NOT NULL,
   Price MONEY  NOT NULL
)
GO

CREATE TABLE Authors (
   AuthorID INT NOT NULL PRIMARY KEY,
   Name VARCHAR(100) NOT NULL
)
GO

ALTER TABLE Books 
ADD CONSTRAINT fk_author 
FOREIGN KEY (AuthorID) 
REFERENCES Authors (AuthorID) ON DELETE CASCADE 
GO
More detail from ...
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s