Ok i found out how you script in 2005, so here it is.SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOIF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblActivedir]') AND type in (N'U'))BEGINCREATE TABLE [dbo].[tblActivedir]( [Id] [int] NOT NULL, [MMG] [nvarchar](30) NOT NULL, CONSTRAINT [PK_tblActivedir] PRIMARY KEY CLUSTERED ( [Id] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]ENDGOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOIF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblPsw]') AND type in (N'U'))BEGINCREATE TABLE [dbo].[tblPsw]( [ID] [int] IDENTITY(1,1) NOT NULL, [ClientId] [int] NOT NULL, [Username] [nvarchar](30) NOT NULL, [Password] [nvarchar](30) NOT NULL, CONSTRAINT [PK_tblPsw] PRIMARY KEY CLUSTERED ( [ID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]ENDGOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOIF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblReports]') AND type in (N'U'))BEGINCREATE TABLE [dbo].[tblReports]( [Reports] [int] IDENTITY(1,1) NOT NULL, [Date] [datetime] NOT NULL, [ClientId] [int] NOT NULL, [Htmltype] [nvarchar](3) NULL, [Arxeio] [binary](50) NULL, CONSTRAINT [PK_tblReports] PRIMARY KEY CLUSTERED ( [Reports] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]ENDGOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOIF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblClient]') AND type in (N'U'))BEGINCREATE TABLE [dbo].[tblClient]( [ID] [int] IDENTITY(1,1) NOT NULL, [Companyname] [nvarchar](50) NOT NULL, [Contactname] [nvarchar](50) NULL, [Phone] [nvarchar](30) NULL, [email] [nvarchar](50) NULL, [FRSid] [int] NULL, [DNSid] [int] NULL, [DHCPid] [int] NULL, [WINSid] [int] NULL, [Comments] [nvarchar](max) NULL, CONSTRAINT [PK_tblClient] PRIMARY KEY CLUSTERED ( [ID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]ENDGOIF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblPsw_tblClient1]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblPsw]'))ALTER TABLE [dbo].[tblPsw] WITH CHECK ADD CONSTRAINT [FK_tblPsw_tblClient1] FOREIGN KEY([ClientId])REFERENCES [dbo].[tblClient] ([ID])ON UPDATE CASCADEON DELETE CASCADEGOIF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblReports_tblClient]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblReports]'))ALTER TABLE [dbo].[tblReports] WITH CHECK ADD CONSTRAINT [FK_tblReports_tblClient] FOREIGN KEY([ClientId])REFERENCES [dbo].[tblClient] ([ID])ON UPDATE CASCADEON DELETE CASCADEGOIF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblClient_tblActivedir]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblClient]'))ALTER TABLE [dbo].[tblClient] WITH NOCHECK ADD CONSTRAINT [FK_tblClient_tblActivedir] FOREIGN KEY([FRSid])REFERENCES [dbo].[tblActivedir] ([Id])GOALTER TABLE [dbo].[tblClient] CHECK CONSTRAINT [FK_tblClient_tblActivedir]GOIF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblClient_tblActivedir1]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblClient]'))ALTER TABLE [dbo].[tblClient] WITH NOCHECK ADD CONSTRAINT [FK_tblClient_tblActivedir1] FOREIGN KEY([DNSid])REFERENCES [dbo].[tblActivedir] ([Id])GOALTER TABLE [dbo].[tblClient] CHECK CONSTRAINT [FK_tblClient_tblActivedir1]GOIF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblClient_tblActivedir2]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblClient]'))ALTER TABLE [dbo].[tblClient] WITH CHECK ADD CONSTRAINT [FK_tblClient_tblActivedir2] FOREIGN KEY([DHCPid])REFERENCES [dbo].[tblActivedir] ([Id])GOIF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblClient_tblActivedir3]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblClient]'))ALTER TABLE [dbo].[tblClient] WITH CHECK ADD CONSTRAINT [FK_tblClient_tblActivedir3] FOREIGN KEY([WINSid])REFERENCES [dbo].[tblActivedir] ([Id])
I had to set "check existing data on creation" to "no"and Insert and Update statements to "no action" in order to pass the fk's between tblactivedir and tblclient, just to saw you the general idea.The problem i see, that also exists if i create a new database and test it, is this...I want a table with a pkey and a description (like tblactivedir) , another table has it's pkey, some othe columns and 2 or 3 or 4 columns that must get the pkey id of the first table (tblactivedir). I cannot undertand why i have a problem. Can't 2 columns of a table reference on the same pkey of another table? If one row of the first table is deleted, then automaticly the columns of the 2nd table that reference this row of the first table will set their values to null. They can do that because they are allowed nulls. Can you answer why sql does not let me reference a pk's table with more than one columns of another table if i set cascading and deleting options to other than "take no action"? I don't want my Updates and deletes to be set at "no action", i want to insert nulls when a row is deleted and cascade when Updated.It won't break any referentian integrity. If a row on the first table is deleted then the referenced rows on the other table will be set to null. What is the problem with that?Thanks.