|
ronedin
Starting Member
29 Posts |
Posted - 2007-10-19 : 06:45:56
|
| Hi,I want to transfer rows from one database to another.SourceMy Source tables in database 'Staging'CustomersEngNameAgeStCodeCityCodeInternalIDCustomersSpanishNameAgeStCodeCityCodeInternalIDCustomersEng and CustomersSpanish contains a replica..only difference being that 'Name' in the CustomerSpanish table is written in spanish language. The Stcode, citycode and Internalid together makes the row unique.Sample scriptCreate table #CustomersEng (name nvarchar(20),age int, st_code int, citycode int, internalid int)Insert into #CustomersEng values('Aron',23,1,1,12);Insert into #CustomersEng values('Cathy',28,1,1,13);Insert into #CustomersEng values('Zarog',33,1,1,14);Insert into #CustomersEng values('Michale',25,1,2,12);Insert into #CustomersEng values('Linda',43,1,2,13);Insert into #CustomersEng values('Burt',53,1,2,14);Create table #CustomersSpanish (name nvarchar(20),age int, st_code int, citycode int, internalid int)Insert into #CustomersSpanish values('Arona',23,1,1,12);Insert into #CustomersSpanish values('Cathylo',28,1,1,13);Insert into #CustomersSpanish values('Zarogo',33,1,1,14);Insert into #CustomersSpanish values('Michalo',25,1,2,12);Insert into #CustomersSpanish values('Lindalo',43,1,2,13);Insert into #CustomersSpanish values('Burto',53,1,2,14);---------------------------------------------------------Destination tables in database 'CMO'CustomerMasterCustomerId (identity) (pk)StCodeCityCodeInternalIDCustomerDetails [customerid and languagecode together are primary keys]CustomerId (fk)NameAgelanguagecodeLanguagelanguagecode (pk)languagenameSCRIPTSCreate table #CustomerMaster (customerid int identity(1,1), st_code int, citycode int, internalid int)Create table #CustomerDetails (customerid int,name nvarchar(20),age int, languagecode int)Create table #CustLanguage (languagecode int, languagename varchar(10))Insert into #CustLanguage VALUES (1,'English')Insert into #CustLanguage VALUES (2,'Spanish')EXPECTED OUTPUTCustomerMaster1 1 1 122 1 1 133 1 1 144 1 2 125 1 2 136 1 2 14CustomerDetails1 Aron 23 11 Arona 23 22 Cathy 28 12 Cathylo 28 23 Zarog 33 13 Zarogo 33 24 Michale 25 14 Michalo 25 25 Linda 43 15 Lindalo 43 26 Burt 53 16 Burto 53 2how do i transfer? thanks |
|