Reputation: 155
I have a main table containing a primary key and there is another TWO table which contains a foreign key to this main table. So if we set delete flag to the row of main table it will set delete flag to the child table also.
How do I write this query?
this is my create statement
CREATE TABLE LOGIN_DETAILS( LOGIN_ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
GROUP_ID INT NOT NULL FOREIGN KEY REFERENCES GROUP_DETAILS(GROUP_ID),
USER_NAME VARCHAR(255) NOT NULL UNIQUE,
PASSWORD VARCHAR(255) NOT NULL,
EMAIL VARCHAR(320) NOT NULL,
CREATED_DATE DATE NOT NULL,
UPDATED_DATE DATE );
Upvotes: 0
Views: 360
Reputation: 407
Not sure what you are asking but if you want to delete records from multiple tables that use foreign key. Use Cascading delete to delete rows from multiple child tables
Upvotes: 1