Link to home
Start Free TrialLog in
Avatar of soozh
soozhFlag for Sweden

asked on

Explain this TSQL

Below is some TSQL from a script that has been generated by Management Studio.

The first command "CHECK ADD CONSTRAINT" creates a foreign key constration, and I guess forces a cascade delete.

What does the second command "CHECK CONSTRAINT "  do?

I am porting the database to a compact database i want to be sure i have included everything.
/****** Object:  ForeignKey [FK_FormData_Units]    Script Date: 08/31/2010 10:16:18 ******/
ALTER TABLE [dbo].[FormData]  WITH CHECK ADD  CONSTRAINT [FK_FormData_Units] FOREIGN KEY([uni_id])
REFERENCES [dbo].[Units] ([uni_id])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[FormData] CHECK CONSTRAINT [FK_FormData_Units]
GO

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sameer2010
sameer2010
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of soozh

ASKER

does this mean that in my case the second statement is not required?

My sql for the compact database is :

ALTER TABLE FormData
ADD CONSTRAINT FK_FormData_Units
FOREIGN KEY(uni_id) REFERENCES Units(uni_id)
ON DELETE CASCADE ;

Do i need to add anything?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial