Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combine 2 dbs files

Status
Not open for further replies.

tziviak2

MIS
Jul 20, 2004
53
US
Is there a way to combine 2 tables-from 2 different databases-they are both students table but they also both have their own autonumber for id-so many numbers are duplicated.
thank you in advance
 
Hallo,

If the Autonumber IDs are duplicated, you obviously won't be able to use the field as a unique identifier, but you can create a new Id and use that in your new database.

If you create a UNION query, you could modify the Id to make it unique.
SELECT 2*lngStudentId as lngNewStudentId, Field2, Field3 FROM tblStudents0
UNION
SELECT 1+2*lngStudentId, Field2, Field3 FROM tblStudents1
would do it.

In this way lngNewStudentId Mod 2 would give you the number of the tblStudents table it came from and the Id within that table would be Clng(lngStudentId/2) (I think that truncates, rather than rounds)

- Frink
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top