Sunday, March 11, 2012

Alter statement to create foreign key relationships

Here is the alter statement that I am trying to use to create a relationship between 2 tables. This does not seem to work on mobile. What am I doing wrong?

ALTER TABLE [SubCategory] CONSTRAINT [FK_SubCategory_Category] FOREIGN KEY([CategoryID])

REFERENCES [Category] ([CategoryID])

ON UPDATE CASCADE

ON DELETE CASCADE

The syntax is ALTER TABLE [] ADD CONSTRAINT []

The SQL Mobile Books Online cover the syntax of the ALTER TABLE statement if you have further questions.

Darren

|||Thanks Darren, I looked in the books online but I must have overlooked that.

No comments:

Post a Comment