Exporting normalized relational data from database to flat file

added by oazabir
8/29/2010 12:12:41 PM

0 Kicks, 71 Views

Sometimes you need to export relational normalized data into flat files where a single row comes from various tables. For example, say you want to export all customer records along with their work and home address, and primary phone number in a single row. But the address and contact information are coming from different tables and there can be multiple rows in those table for a single customer. Sometimes there can be no row available in address/phone table for a customer. In such a case, neither INNER JOIN, nor LEFT JOIN/OUTER JOIN will work. How do you do it? Solution is to use OUTER APPLY.