Last post May 13, 2010 04:02 PM by juliaji999
Apr 30, 2008 03:32 PM|funluckykitty|LINK
I have a basic sql statement, where I have a usersID, and I want to joing that usersID to another table in another database to get the users first and last names. How do I join across databases... each with a different connection string?
Here's what I want..
Select usersID from tableA in databaseA, and usersFirstName, usersLastName from table B in database B where the usersID from tableA = the usersID in tableb.
Apr 30, 2008 04:21 PM|che3358|LINK
You can't do that on fly directly. You have two options:
1. Create a linked server in DB invironment, then create a SP to take care of it.
2. Get two DataSets for them, then merge two datatables into one based on usersID.
Hope it gives you some idea.
Apr 30, 2008 04:37 PM|limno|LINK
Apr 30, 2008 06:11 PM|che3358|LINK
Limno is correct. I thought you wanted to join two tables in two DBs within different servers.
Apr 30, 2008 07:15 PM|funluckykitty|LINK
Same server, two different sql databases each with their own database connection.
May 01, 2008 03:59 PM|funluckykitty|LINK
Works perfectly!. Just needed help visualizing how it would fit together. THANK YOU!!! :-)
May 13, 2010 04:02 PM|juliaji999|LINK
Get two DataSets for them, then merge two datatables into one based on usersID.
1, how to merege on userID?
2, IN database I can make query from 2 tables can get 3rd result-
SELECT a.userID, b.usersFirstName, b.usersLastName
FROM databaseA.dbo.TableA a
inner join database B.dbo.TableB b
3, from 2 datasets, ds1 may have 5 columns - from SQL Server database,
ds2 may have 3 columns - may from ORACLE or DB2
how can I merge these 2 datasets to get 3rd ds, that may have 4 columns?
ds1.Tables.Rows join ds2.Tables.Rows or ds1.Tablea.Columns ?
Could you give me an example code for it?
and replay to my both email
"ASP.NET and SQL Server"