Viewing 10 posts - 1 through 11 (of 11 total)
A surrogate key will mean changing all the tables fields that refer to Users, which is a suicide duty. There's too many data and too many tables. But I'll take...
March 7, 2012 at 8:27 am
No, I'm afraid that a surrogate key wouldn't solve the problem. I'll test the first option and tell you the results 🙂
March 7, 2012 at 7:40 am
Ok. I was able to create the two foreign keys, but: what if the ID (primary key) from the user changes (say, from tmosby to tedmosby)? I need all the...
March 7, 2012 at 7:32 am
Sorry John, I found the bug. I did the second foreign key with a different column. Instead of Modified_by_Users I used another one called Manager_users, which also refer to the...
March 7, 2012 at 6:46 am
This is what I get:
FK_Companies_UsersCompanies2012-03-07 14:11:14.8572012-03-07 14:11:14.857
So, this seem to confirm that there's already one foreign key pointing from Users (ID) to Companies (Created_by_user). But now, I need to create...
March 7, 2012 at 6:38 am
This is the statement I wrote in the query for the second foreign key (The first, Created_By_User, was already created in the database as you can see in the code...
March 7, 2012 at 6:20 am
[>Modified By Users Name] is the column on which you place the constraint, so you need to change that to the new column, not add it as an extra column.
If...
March 7, 2012 at 4:59 am
Could I write something like this?
ALTER TABLE [dbo].[Companies] WITH CHECK ADD CONSTRAINT [FK_Companies_Users] FOREIGN KEY([>Created By Users Name], [>Modified By Users Name])
REFERENCES [dbo].[Users] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
Thanks.
March 7, 2012 at 4:37 am
Companies:
USE [CRM]
GO
/****** Object: Table [dbo].[Companies] Script Date: 03/07/2012 12:07:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Companies](
[ID] [nvarchar](255) NOT NULL,
[Date Creation] [datetime] NULL,
[Date Modification] [datetime] NULL,
[>Created By...
March 7, 2012 at 4:11 am
I haven't used triggers to do this. I just built it on the diagram of the database. As I said before, i know very little of programming, so I use...
March 7, 2012 at 3:59 am
Viewing 10 posts - 1 through 11 (of 11 total)