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
 SQL Server Development (2000)
 Select id from multiple tables into view

Author  Topic 

jns
Starting Member

19 Posts

Posted - 2002-09-15 : 08:01:25
I'm trying to create a view that contains the id number from three different tables into one column within the view.

I'm doing this to make sure I have unique id numbers across all three tables.

I tried creating a stored procedure that inserted all the information into a temp table and then calling the stored procedure from the view but apparently that can't be done.

Any suggestions?

Onamuji
Aged Yak Warrior

504 Posts

Posted - 2002-09-15 : 08:28:30
doing this in a view is not a good solution (or even possible?)

doing this in a stored procedure definitely is not a good solution... the ID number cannot be guarenteed to be unique for every row every time you call it ...

you will want to create a merge table that contains all three rows... if you can't change the way the application accesses data in these three tables ... you should create a merge table any way and leave the three there and use triggers to keep the merge table in sync with the three others ...

one question you might want to answer is do the other three tables have unique (primary key) columns?

Go to Top of Page

jns
Starting Member

19 Posts

Posted - 2002-09-15 : 10:08:27
Yes each of the three tables' id field is unique to itself but not to each other. In hindsight I with the original DBA had setup one table for the ids and relational tables to the three main and reconfiguring the DB based upon all the supporting code/sp is not an option.

Go to Top of Page

Onamuji
Aged Yak Warrior

504 Posts

Posted - 2002-09-15 : 10:48:23
so what's the need for a single table that combines all three... provide the DDL for the three tables and we'll see if we can do something for you... make sure to explain all relationships ... and don't include just columns of importance...

Go to Top of Page
   

- Advertisement -