Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Problem w/ alter table Constrain foreign key

Author  Topic 

Larethian
Starting Member

1 Post

Posted - 2004-06-29 : 05:09:42
I'm working w/ Ms sql server 2000.
I'm trying to make a constraint with a foreign key that reference a ref_table (ref_column) but when I put ON DELETE CASCADE or ON DELETE NO ACTION or ON UPDATE NO ACTION or ON UPDATE CASCADE Sql server told me that got something wrong near ON. I try everthing but only works when I put nothing.
Anybody with the same problem? any solution?

The line I'm trying is:
ALTER TABLE [Arrecife].[dbo].[Willi] WITH CHECK ADD CONSTRAINT [FK_Willi_Willi2] FOREIGN KEY ( [sdasd] ) REFERENCES [Arrecife].[dbo].[Willi2 ] ([asnl dskaj dl]) ON DELETE NO ACTION ON UPDATE NO ACTION


where [Arrecife].[dbo].[Willi] is my database and my table
[FK_Willi_Willi2] is the name of my table constraint
( [sdasd] ) is the column I select from the table.
[Arrecife].[dbo].[Willi2 ] is my foreign database and my foreign table
([asnl dskaj dl]) is my foreign column.

there are indexes in both tables, but not use neither of the columns.

Sorry by my english, I'm from Spain (Europe).

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2004-06-29 : 08:05:47
Check the compatibility level of the database, it might have been set to 70 (compatible with SQL Server 7), in which case it will not accept cascade options as part of a constraint. Run sp_helpdb 'database name' and see the value for compatibility_level. This should be set to 80.

OS
Go to Top of Page
   

- Advertisement -