July 21, 2013 at 10:31 pm
Table1:
Reportid | IdetityID(Pimary key)
-------- | ---------
2 |1
22
23
24
25
Table2:
Reportid | IdetityID(Primary key)
-------- | ---------
3|1
3| 2
3|3
34
35
I want to insert above values in to Table3 leke below:
Hear Problem is i want to give relations ship above
Table1 and Table2 Primary keys Reference to TABLE3 Forigen key Identity Column.
Is there any posibility give me solution
Table3:
Reportid IdetityID(Forigen key)
-------- ---------
31
32
33
34
35
21
22
23
24
25
July 22, 2013 at 12:58 am
you can create two foreign key constraint refering table table1 and table2 in your new table table3...
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
July 22, 2013 at 1:20 am
Thanks for your reply, I was try for this , but error msg was showing for that. do you have any example quer...
July 22, 2013 at 1:28 am
mahi123 (7/22/2013)
Thanks for your reply, I was try for this , but error msg was showing for that. do you have any example quer...
what error message you got?
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
July 22, 2013 at 2:22 am
Table3(dbo) table - Unsable to create relationship 'FK_Table1' the alter statement conflicted With FOREIGN KEY Constraint 'FK_Table1' The conflicted Occures 'DB_DEV', table 'dbo.table1'
July 22, 2013 at 7:41 am
In order to help we will need a few things:
1. Sample DDL in the form of CREATE TABLE statements
2. Sample data in the form of INSERT INTO statements
3. Expected results based on the sample data
Please take a few minutes and read the first article in my signature for best practices when posting questions.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 23, 2013 at 12:38 am
You should not declare a foreign key constraint referring two different tables based upon one single column. What if a key value is in one but not contained in the other table? You would get an error message that your key hurts data integrity.
I would advise you to rethink your design.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply