Blog Post

Azure Database Support Blog
1 MIN READ

Lesson Learned #358:Error SQL46010-contains a statement that is not supported on Azure SQL Database

Jose_Manuel_Jurado's avatar
May 29, 2023

Today, we got a service request that our customer faced the following error message: Error SQL46010: Procedure: [dbo].[XYZ] contains a statement that is not supported on Microsoft Azure SQL Database v12. The specific error is: Incorrect syntax near '1252'. I would like to share with you the lessons learned.

 

The first thing that we need to pay attention is trying to find the text of this incorrect syntax error: The specific error is: Incorrect syntax near '1252'. The error message indicates that the statement in the stored procedure [dbo].[XYZ] contains a syntax error that is not supported on Microsoft Azure SQL Database v12. The error message states that there is an incorrect syntax near '1252'.

Based on the following code, it appears that the error is coming from the BULK INSERT statements. Specifically, the CODEPAGE option is causing the error.

 

BULK INSERT Table1
FROM 'XYZ.txt'
WITH (DATA_SOURCE = 'DataSource',
FIRSTROW = 1,
    FIELDTERMINATOR = ';',  --CSV field delimiter
    ROWTERMINATOR = '\\n',   --Use to shift the control to next row
FORMAT = 'CSV',
DATAFILETYPE='char',
CODEPAGE = '1252',
TABLOCK
)

 

As CodePage parameter is not supported in Microsoft Azure SQL Database, you need to comment or remove this option to be able to execute the query. 

 

Enjoy!

Published May 29, 2023
Version 1.0

1 Comment

  • albertozgz's avatar
    albertozgz
    Copper Contributor

    Oh, we know about this:

     

    TIP 1: Codepage will work on OpenRowset + Az DB without problem

      But you will have another problem later. Some syntax wont compile on Az Data Studio Database Project (extension), you will have an error

      This has been ACK as ahttps://github.com/microsoft/azuredatastudio/issues/22891

     

      OpenRowset is the Key of "Data Virtualization"  

        (No tested on Synapse Database Project, but synapse have an alternative solution)

     

    TIP 2:  If you use codepage on OpenRowset  + FMT file, the collation must be removed from FMT file (because have preference over codepage) otherwise codepage won't be applied, and you will lost hours of tests. This is commented in the FMT but no in the Openrowset manual