insert z_temp_kgpcrm_account_customer
select coalesce(c.[Name], ' ') as [Account Name],
coalesce(contact.name, ' ') as [Primary Contact],
c.[No_] as [Account Number],
c.[Bill-to Customer No_] AS Parent_Account,
c.[Bill-to Customer No_] AS Parent_Account_no,
CASE WHEN c.[E-Mail] > ' ' THEN c.[E-Mail]
-- WHEN [Contact 1 E-Mail] > ' ' THEN [Contact 1 E-Mail]
-- WHEN [Contact 2 E-Mail] > ' ' THEN [Contact 2 E-Mail]
-- WHEN [Contact 3 E-Mail] > ' ' THEN [Contact 3 E-Mail]
ELSE ' ' END AS EMAIL ,
c.[Phone No_] AS [Main Phone],
case when c.[Contact 1 Phone] > ' ' then c.[Contact 1 Phone]
-- when c.[Contact 2 Phone] > ' ' then c.[Contact 2 Phone]
-- when c.[Contact 3 Phone] > ' ' then c.[Contact 3 Phone]
else ' ' end AS [Other Phone],
C.[Fax No_] AS [Fax],
' ' as Website,
'Other' AS [Address 1: Address Type],
c.Name AS [Address 1: Name],
c.[address] AS [Address 1: Street 1] ,
c.[address 2] AS [Address 1: Street 2] ,
' ' AS [Address 1: Street 3],
c.city AS [Address 1: City],
c.county AS [Address 1: State/Province],
c.[Post Code] AS [Address 1: ZIP/Postal Code],
c.[country_region code] AS [Address 1: Country/Region],
' ' AS [Address Phone],
c.[shipping agent code] AS [Address 1: Shipping Method],
[Shipment Method Code] AS [Address 1: Freight Terms],
' ' AS [Description],
c.[customer class] AS [Industry],
'' AS [Annual Revenue],
'' AS [No. of Employees],
'' AS [SIC Code],
'' AS [Ownership],
'' AS [Ticker Symbol],
'' AS [Territory],
'Customer' as [Relationship Type],
'' AS [Category],
'US Dollar' AS [Currency],
[Credit Limit (LCY)] AS [Credit Limit],
[On Credit Hold] AS [Credit Hold],
c.[Payment Terms Code] AS [Payment Terms],
'' AS [Price List],
CASE WHEN [Inside Salesperson Name] > ' ' THEN 'kgp\' + [Inside Salesperson Name] ELSE [OUTSIDE Salesperson Name] END AS [Owner],
'' AS [Preferred Method of Contact],
'' AS [Do not allow Emails],
'' AS [Do not allow Phone Calls],
'' AS [Do not allow Mails],
'Y' AS [Do not allow Bulk Emails],
'' AS [Do not allow Faxes],
'' AS [Originating Lead],
'' AS [Send Marketing Materials],
'' AS [Preferred Day],
'' AS [Preferred Time],
'' aS [Preferred Service],
'' AS [Preferred Facility/Equipment],
'' AS [Preferred User],
rtrim(c.[Name]) + '-' + c.[No_] + '-C' AS [Unique ID],
[Inside Salesperson Name] AS [PPOC],
'' AS [Vertical],
c.[customer route group],
CASE WHEN c.[Customer Posting Group] = 'INACTIVE' THEN DEM.[Dimension Value Code] ELSE c.[Customer Posting Group] END AS CUSTOMER_POSTING_GROUP,
CASE WHEN c.[Customer Posting Group] = 'INACTIVE' THEN 'I' ELSE 'A' END as account_status,
--c.[credit analyst],
case when credit_analyst.name > ' ' then COALESCE(credit_analyst.name,' ') else c.[credit analyst] end AS [credit analyst],
'' AS [KGP Sales Revenue],
--additions-- 01/26/14
'N/A' as [buyer code] ,
[Our Account No_] as [contract #],
0 as [Min Order Value],
'N/A' AS [Freight Allowed],
Sales_Person.[Name] as Salesperson
--into dbo.z_temp_crm_account
what is the code doing here
?