TAGS :Viewed: 4 - Published at: a few seconds ago

[ Multiple 2 different colums from 2 different databases ]

I am producing this

Inpatient Days NICU rate    
1              900.00

These two columns are listed on different databases on different servers so database a has inpatient days and database b has nicu rate. How do I multiply Inpatient days * Nicu rate and get a new column called total allowed?

Answer 1

Here is an example of how to do that http://stackoverflow.com/a/1144070/2560997

Basically just do the next:

select *
from LocalTable, [OtherServerName].[OtherDB].[dbo].[OtherTable]

Answer 2

If both db in the same server, then the syntax is

    a.quotename[Inpatient Days], b.quotename[NICU rate]    
    databasename.a ,databasename.b
--where condition if there, other wise cartesian product result comes

If both db in different database , then as above suggest use link server syntax.

you can replace this heirarchy by DOT(.)

SQL dot notation