Skip to content

SQLServerBulkCopy / getDestinationMetadata fails when there's an apostrophe in the table name #775

@Gaff

Description

@Gaff

Driver version or jar name

mssql-jdbc:6.4.0-jre8

Problem description

When attempting to bulk upload to a table with ' in the name the upload fails with:

com.microsoft.sqlserver.jdbc.SQLServerException: Unable to retrieve column metadata.
at 

com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.getDestinationMetadata(SQLServerBulkCopy.java:1781)

The code does queries such as:

select collation_name from sys.columns where " + "object_id=OBJECT_ID('" + destinationTableName + "') 

Which fails because destinationTableName contains unescaped '

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in the driver. A high priority item that one can expect to be addressed quickly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions