0

I have imported data from .csv file to temp table and it is like

ID          DEPARTMENT      DESIGNATION       LOCATION     REGION       STATE

Test19768   Barclays|Citi Bank|Ireland      developer   NULL    NULL    NULL

and have to update/insert in EMp table like

ID          DEPARTMENT      DESIGNATION   LOCATION        REGION        STATE
Test19768   Barclays        developer       NULL            NULL        NULL
Test19768   Citi Bank|      NULL            NULL            NULL        NULL
Test19768   Ireland         NULL            NULL            NULL        NULL

Need to insert multiple pipe separated value for each user ID. we can't use STRING_SPLIT as we have version 14.

Girish
  • 11
  • 3

1 Answers1

0

check this

BULK INSERT TempTable
    FROM 'C:\CSVData\your.csv'
    WITH
    (
        FIRSTROW = 2,
        FIELDTERMINATOR = '|',  --CSV field delimiter
        ROWTERMINATOR = '\n',   --Use to shift the control to next row
        ERRORFILE = 'C:\CSVDATA\ErrorRows.csv',
        TABLOCK
    )

Related Post

Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72
  • FIELDTERMINATOR is comma by actual data is pipe separated and hence need to split that data and insert into another table – Girish Jan 09 '19 at 09:45