Formatting code with BulkInsert and CODEPAGE

JR_GERJR_GER Posts: 4 New member
edited February 10, 2021 2:22PM in SQL Prompt
Hi,
In a stored procedure, I'm using "BULK INSERT" to import a CSV which is UTF-8 encoded.
So the code looks like:
--->8  SNIP ---
BULK INSERT tbl_XYZ<br>FROM 'D:\Imports\txt.csv'<br>WITH<br>(<br>&nbsp;CODEPAGE = '65001'<br>,FIELDTERMINATOR = '@@@'<br>,ROWTERMINATOR = '\n'<br><div>)</div>
--- SNAP  8< ---
But SQL Prompt is throwing an error if I want to format the code:

If I comment out this line, formatting works well.
Where's the problem here?
TIA
JR

Best Answer

  • SujaySujay Posts: 54 Bronze 3
    edited February 19, 2021 6:39AM Answer ✓
    Hi Joachim,

    Unfortunately, it is the Microsoft Parser which we use for formatting causing the parsing error.
    The error occurs due to the value of CODEPAGE being supplied in quotes 
    However, if the script is modified as below, the parsing errors are not observed.




    Could you check if this works for you?

    Regards,
    Sujay Diwan

    Sujay Diwan| Product Support Engineer | Redgate Software

Answers

Sign In or Register to comment.