October 22, 2013 at 2:57 am
Hello all,
Very new to this all.
Using SMS2008R2, I'm trying to define a relationship between two columns in two tables. I get this error -
The columns in table 'aspnet_Membership (dbo)' do not match an existing primary key or UNIQUE constraint.
Any ideas?
Tx,
Martin
October 22, 2013 at 3:09 am
How are you trying to define the relationship?
Can you post the DDL of the tables involved?
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
October 22, 2013 at 6:26 am
Thanks Koen.
Can't answer your questions fully I don't think as I am not really up to speed on DB terminology 🙂
About defining the relationship, I am doing it inside SQL Management Studio 2008 by choosing the FK column from Table 1 and then trying to created the PK-FK relationship from that point. Open to any other better suggestions 🙂
DDL? Don't know what that means. In any case, could I use SMS to get a DDL of the tables? If so, how?
Greetings,
Martin
October 22, 2013 at 7:14 am
DDL = Data Definition Language
It is essentially the metadata that describes the make-up of the table... columns, data types etc...
What kind of relationship are you trying to create and again how are you trying to create it?
In the Databse Diagramming or Design Tool or with TSQL?
October 23, 2013 at 12:52 am
Apologies about the seemingly inane questions, but this is like learning a new language.
I'm trying to create a PK-FK relationship between two columns in two separate tables. The PK is from the 'aspnet_Membership (dbo)' table (the column which holds the users email), and the FK is from a new table I created which stores extra user information. I would like the user's email address reflected in this table.
How am I trying to achieve it? I'm not using TSQL - that I know 🙂 Using SMS2008 I select the column that will be my FK and then use the Relationships button from a toolbar at the top of the page.
Again, apologies if the info I give is less than clear, but this all new to me.
Tx,
Martin
October 23, 2013 at 1:12 am
Martin,
Make sure that there is a primary key defined on the column you are connecting to, it will have a yellow key displaying. From what I can read that is probably your problem.
For what a DDL is have a look in help for create table T-SQL. This will then give you the full explanation of the create table DDL. You can have a look at the DDL of the table you are working with by right clicking and selecting script to new query window, script the create statement and it will output the DDL. There are scripting option but I don't have SMSS in front of me so I can't remember the key strokes but have a play and a look to see what if any differences the scripting options make.
Welcome to the world of databases, this sounds like one of the first tasks you've done. Good luck
October 23, 2013 at 1:25 am
Thanks Mr or Mrs (whichever it may be 🙂 )
The 'aspnet_Membership (dbo)' table in which the "Email" column resides already has a primary key set on another column (UserID). And I suppose that is where my poor logic, design and naivety is exposed!
That begs the question - how do I get the values from the Email column in the 'aspnet_Membership (dbo)' table represented in my new UserPofiles table?
And thanks for the welcome BTW 🙂
Martin
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply