Skip to content

Bulk insert fails when computed field in table #2

@markweissman

Description

@markweissman

I'm trying to bulk insert into a table that had a computed column, particularly:

create TABLE [dbo].[tstBCPComputedColumn] (
Id int not null identity(1,1) UNIQUE,
Code varchar(4096) not null,
Format varchar(10) not null default 'xml',
Hash
AS CAST(hashbytes('SHA1',[Code]) AS VARBINARY(20))
PERSISTED NOT NULL,
DateInserted DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CreatedBy varchar(30) NOT NULL DEFAULT CURRENT_USER,
CONSTRAINT pk_enumTestBCPComputedColumn PRIMARY KEY(Id))

I'm using

conn.bulk_insert(table, batch, batch_size=batch_size)

from ctds and providing all columns. If I remove the Hash column from the table, it works well.
With that column,

_tds.ProgrammingError: ('unrecognized msgno', 'query', 'BCP [BOS-DBRESEARCH01].mweissman.dbo.tstBCPComputedColumn', 'params', 'None', 'connection', 'DRIVER={FreeTDS};TDS_Version=8.0;ClientCharSet=ISO8859-1;SERVER=BOS-DBRESEARCH01;PORT=1433;VAULT_NAME=db-research01;DATABASE=master', 'type', 'ProgrammingError')

I've tried passing in:

  • 0
  • b''
  • None
  • leaving out the Hash column from batch
  • passing dictionaries without Hash

but none of those work. Is this supported? Can you provide some advice on how to insert into this table?

This works with pymssql btw but I need kerberos support which only ctds has.

Thanks, Mark Weissman

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions