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 2005 Forums
 Transact-SQL (2005)
 Create table

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2007-10-17 : 19:43:20
Hello,

I am creating a table as follows:

create table dbo.FilesCategories
(
FileID uniqueidentifier not null,
CategoryID uniqueidentifier not null,
constraint PK_FilesCategories
primary key clustered (FileID, CategoryID),
constraint FK_FilesCategories_Files
foreign key(FileID)
references dbo.Files(FileID),
constraint FK_FilesCategories_Categories
foreign key(CategoryID)
references dbo.Categories(CategoryID)
)


When I add "on delete cascade" VS 2008 gives me an error and outlines my code with a blue line. Am I doing something wrong?
...
constraint FK_FilesCategories_Files
foreign key(FileID)
references dbo.Files(FileID)
on delete cascade,
constraint FK_FilesCategories_Categories
foreign key(CategoryID)
references dbo.Categories(CategoryID)
on delete cascade
...

Thanks,
Miguel

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-10-17 : 19:43:55
Got the error? Does it work if you run it in SSMS?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2007-10-17 : 20:01:16
Hi,

Very strange, in the editor I get a blue outline the moment I add the cascade delete but when i run the script it works fine ...

... have no idea why. Going to check some VS 2008 docs.

Thanks,
Miguel
Go to Top of Page
   

- Advertisement -