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.
Author |
Topic |
satya068
Posting Yak Master
233 Posts |
Posted - 2010-08-09 : 05:50:45
|
I am looking to get sql script to the below query,i have two table in my databases APPOINTMENTS and ADMISSIONS in admissions table there are 4000 records where i need to replace REFERRAL_DATE column in ADMISSIONS with APPOINTMENT_DATE column from APPOINTMENTS table,KEY_CODE is the common column in both table.for the 4000 records in ADMISSIONS table if the key_code matches with key_code in APPOINTMENTS table then for that record the data in the column REFERAL_DATE needs to replace with APPOINTMENT_DATE from Appointments table.if u have any idea about this script please let me know.thanksSatya |
|
PavanKK
Starting Member
32 Posts |
Posted - 2010-08-09 : 06:18:44
|
UPDATE ADSET AD.REFERAL_DATE = AP.APPOINTMENT_DATEFROM ADMISSIONS ADJOIN APPOINTMENTS AP ON AD.KEY_CODE = AP.KEY_CODEKK |
 |
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-08-09 : 06:33:51
|
Thanx pavan,i am sorry, i forgot to mention that appointments in EMP_DB(database)and admissions table in ADM_DB ,can you help me in wrinting the sql from two diff databases. quote: Originally posted by PavanKK UPDATE ADSET AD.REFERAL_DATE = AP.APPOINTMENT_DATEFROM ADMISSIONS ADJOIN APPOINTMENTS AP ON AD.KEY_CODE = AP.KEY_CODEKK 
Satya |
 |
|
PavanKK
Starting Member
32 Posts |
Posted - 2010-08-09 : 06:43:42
|
Try thhisUPDATE ADSET AD.REFERAL_DATE = AP.APPOINTMENT_DATEFROM ADM_DB..ADMISSIONS ADJOIN EMP_DB..APPOINTMENTS AP ON AD.KEY_CODE = AP.KEY_CODEKK |
 |
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-08-09 : 07:02:31
|
its worked.Thanx for ur help pavan.quote: Originally posted by PavanKK Try thhisUPDATE ADSET AD.REFERAL_DATE = AP.APPOINTMENT_DATEFROM ADM_DB..ADMISSIONS ADJOIN EMP_DB..APPOINTMENTS AP ON AD.KEY_CODE = AP.KEY_CODEKK 
Satya |
 |
|
|
|
|