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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 FOREIGN KEY

Author  Topic 

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2003-02-02 : 18:35:04
I have a table such that three columns all reference the same column in the POINT table.

I tried the code below but it barfs on having point_id 3 times. if I have point_id once then it complains about the wrong number of columns....

ALTER TABLE [LC2IEDM].[dbo].[POINT_REF] ADD
FOREIGN KEY (
[point_ref_orgn_point_id],
[point_ref_x_vector_point_id],
[point_ref_y_vector_point_id]
) REFERENCES [LC2IEDM].[dbo].[POINT] (
[point_id],
[point_id],
[point_id]
)


Can someone please point out where I'm going wrong?

Thanks in advance

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"

nr
SQLTeam MVY

12543 Posts

Posted - 2003-02-02 : 18:47:07
This would mean that
[point_ref_orgn_point_id],
[point_ref_x_vector_point_id],
[point_ref_y_vector_point_id]

All have to be the same value ([point_id]) so it would be a waste of time having the three columns.
I think you mean they all have to be valid [point_id] so

ALTER TABLE [LC2IEDM].[dbo].[POINT_REF] ADD
FOREIGN KEY ([point_ref_orgn_point_id]) REFERENCES [LC2IEDM].[dbo].[POINT] ([point_id])
ALTER TABLE [LC2IEDM].[dbo].[POINT_REF] ADD
FOREIGN KEY ([point_ref_x_vector_point_id]) REFERENCES [LC2IEDM].[dbo].[POINT] ([point_id])
ALTER TABLE [LC2IEDM].[dbo].[POINT_REF] ADD
FOREIGN KEY ([point_ref_y_vector_point_id]) REFERENCES [LC2IEDM].[dbo].[POINT] ([point_id])


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2003-02-02 : 18:54:15
Ta

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page
   

- Advertisement -