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
 General SQL Server Forums
 New to SQL Server Programming
 Joining two columns form two tables from two DB's

Author  Topic 

luckycsc
Starting Member

7 Posts

Posted - 2009-02-12 : 10:53:04
Hello All,

Can anyone please help me out with this.

I have a column called Institution_name in a table Institution in a database named "INS"
This column looks like
Institution_Name
Columbia
Harvard
Berkley


I have another column called Roles in a table USER_ROLES in a database named "RLS"
This column loooks like
Roles
Master
Student
Professor

I want to merge these two columns into one....and name the resulting column as XYZ and it should look like

XYZ
Columbia:Master
Harvard:Student
Berkeley:Professor


Can anyone please help me out how would this be possible. I guess there should be something called "CONCAT" command, but I am not sure how that works for joining columns in different databases

THANKS A LOT!!!!

Arjun

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-12 : 10:55:00
please dont post here if you want oracle specific solutions

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=119681
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-12 : 10:56:08
also didnt you still understand how to do this? you already posted solution there
Go to Top of Page

luckycsc
Starting Member

7 Posts

Posted - 2009-02-12 : 10:59:04
I guess this is a sql statement for which I was looking.
The solution I posted there was for joining two columns from the same table in a database...this is joining two columns from tables of different databses...

Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-12 : 11:01:10
quote:
Originally posted by luckycsc

I guess this is a sql statement for which I was looking.
The solution I posted there was for joining two columns from the same table in a database...this is joining two columns from tables of different databses...

Thanks


it may be sql staement that you want. but this forum is for MS SQL Server only, so solutions provided here will be only be according to MS SQL Server syntax. If you're using any other RDBMS like oracle, these solutions wont necessarily work
Go to Top of Page

luckycsc
Starting Member

7 Posts

Posted - 2009-02-12 : 11:04:05
I am using My SQL only, not Oracle....
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-12 : 11:06:02
My SQL and SQL Server are 2 different RDBMS.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-12 : 11:07:37
quote:
Originally posted by luckycsc

I am using My SQL only, not Oracle....


This is not MySQL but MS SQL Server forum
Go to Top of Page

luckycsc
Starting Member

7 Posts

Posted - 2009-02-12 : 11:08:11
Yes, but the sql can be the same.....I am looking for SQL queryto merge the columns, either SQL Server or MYSQL is fine....

Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-12 : 11:21:53
even in that case you should have a column on each table by which rows are related. or else how will you deterime which row of one table should be merged with which. keep in mind that you dont have concept of position in sql server unless you specify it based on unique valued column.
Go to Top of Page

luckycsc
Starting Member

7 Posts

Posted - 2009-02-13 : 11:56:42
Thanks a lot to all of you....

I got the solution, In SQL Server also this can be done by using CONCAT Operator.....jusrt you need to mention databasename.tablename at the end

Thanks
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-13 : 21:09:42
quote:
Originally posted by luckycsc

Thanks a lot to all of you....

I got the solution, In SQL Server also this can be done by using CONCAT Operator.....jusrt you need to mention databasename.tablename at the end

Thanks



Never heard of CONCAT operator in SQL Server.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-14 : 00:53:11
concat operator is + in SQL Server
Go to Top of Page
   

- Advertisement -