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
 General SQL Server Forums
 New to SQL Server Programming
 problem with relationship.

Author  Topic 

coldfiretech
Starting Member

30 Posts

Posted - 2009-04-06 : 02:16:54
hello everyone.. im having an issue setting up a cascade on a relationship between two tables.. when i leave the delete action to 'no action' it doesnt give me any errors but ofcourse i want to utilize this method.

Im getting this error when i try to set the delete action to null.


'csUsers' table saved successfully
'csPhoneNumbers_Requests' table
- Unable to create relationship 'FK_csPhoneNumbers_Requests_csUsers1'.
Introducing FOREIGN KEY constraint 'FK_csPhoneNumbers_Requests_csUsers1' on table 'csPhoneNumbers_Requests' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Could not create constraint. See previous errors.

CREATE TABLE [dbo].[csPhoneNumbers_Requests](
[ID] [uniqueidentifier] NOT NULL,
[OwnersUserID] [uniqueidentifier] NULL,
[OwnersEmail] [varchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[PhoneNumberID] [uniqueidentifier] NULL,
[PhoneNumber] [char](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[RequestingUserID] [uniqueidentifier] NULL,
[RequestingEmail] [varchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[RequestDate] [datetime] NOT NULL,
[RequestStatus] [tinyint] NOT NULL,
[DeleteDate] [datetime] NULL,
CONSTRAINT [PK_csPhoneNumbers_Requests_1] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[csPhoneNumbers_Requests] WITH CHECK ADD CONSTRAINT [FK_csPhoneNumbers_Requests_csPhoneNumbers] FOREIGN KEY([PhoneNumberID])
REFERENCES [dbo].[csPhoneNumbers] ([ID])
ON DELETE SET NULL
GO
ALTER TABLE [dbo].[csPhoneNumbers_Requests] CHECK CONSTRAINT [FK_csPhoneNumbers_Requests_csPhoneNumbers]
GO
ALTER TABLE [dbo].[csPhoneNumbers_Requests] WITH CHECK ADD CONSTRAINT [FK_csPhoneNumbers_Requests_csUsers] FOREIGN KEY([OwnersUserID])
REFERENCES [dbo].[csUsers] ([ID])
ON DELETE SET NULL
GO
ALTER TABLE [dbo].[csPhoneNumbers_Requests] CHECK CONSTRAINT [FK_csPhoneNumbers_Requests_csUsers]



please help me.. i need to set the value of the RequestingUserID in the to null when the user is deleted.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-04-07 : 11:03:04
are you using sql 2005? ON DELETE SET NULL is only available from sql 2005
Go to Top of Page
   

- Advertisement -