I have 3 Database
- ECPNWEB
- ECPNDB
- ECPNPOS
and also 3 tables
- account -> ECPNWEB
- branch -> ECPNDB
- terminal -> ECPNPOS
and the tables having multiple columns
- account (accntid,managedby,account,first,last,....)
- branch(branch_code,company_code,name,distributor,cutoff,....)
- terminal(retail,brand,model,serial,status,....)
All I want to do is to get the specific column.,
my desired output is:
managedby for table account and ECPNWEB database
name for table branch and ECPNDB database
model for table terminal and ECPNPOS database..
Like this
|managedby|name|model
Thanks in advance
sp_addlinkedserver()
is what you need
exec sp_addlinkedserver @server = '*server_name*'
//---replace *server_name* with yours
- it will look like this: e.g.
select * from [server].[database].[schema].[table]
- Check out this link http://msdn.microsoft.com/en-us/library/ms190479.aspx
I'm not about it but try this and tell me what is the o/p. For example you can try this way
SELECT firstdb.*, seconddb.*
FROM Server1.Database1.dbo.myTable AS firstdb
INNER JOIN Server2.Database2.dbo.myTable AS seconddb
ON firstdb.id = seconddb.id
EDIT2: try this,not sure this will give u desired result, not tested... replace *column_name* with yours
SELECT account.managedby, branch.name, terminal.model FROM ECPNWEB.dbo.account, ECPNDB.dbo.branch, ECPNPOS.dbo.terminal AS a INNER JOIN account ON account.(column_name)=branch.(column_name) INNER JOIN terminal ON account.(column_name)=terminal.(column_name)