Link to home
Start Free TrialLog in
Avatar of Syswatch6000
Syswatch6000Flag for Denmark

asked on

MSSQL Query from MySQL

Hi there...
I'm not that good in SQL, and I need help creating a SQL query.

I have a database with 3 tables, and some data that I need to be copied to another database, with another table structure.

Source Database Tables.
CONTACT
  contact_id (key to PHONE.owner_id)
  name
  orgNr
  country_id (key to COUNTRY.country_id)

COUNTRY
  country_id
  diallnPrefix

PHONE
  owner_id
  searchPhoneNumber


DESTINATION TABLE
  Recid
  Number
  Name

Insert to destination table should be like this:
"autofill", "contact.orgNr - contact.name", "+country.diallnPrefix-searchPhoneNumber"

I hope you guys understand what I'm trying to do, and that you can help me with the MSSQL query string for this.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Jared_S
Jared_S

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of santhimurthyd
Try with this

select con.orgNr + '-'+ con.name , '+' + cnt.diallnPrefix +'-'+ phn.searchPhoneNumber from Contact con
      inner join country cnt on con.country_id = cnt.country_id
      inner join Phone phn on con.contact_id = phn.owner_id