Skip to content

Import-Dbacsv fails with -KeepNulls  #4999

@spaghettidba

Description

@spaghettidba

Before submitting a bug report:

  • Ensure you are able to reproduce it on the latest released version (we release often)
  • Verified this bug is not already reported in an issue
  • Verified errors are not related to permissions
  • Can reproduce in a clean PowerShell session (clean = powershell -NoProfile)

Steps to Reproduce

-- create table to use for csv import
USE [tempdb]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[DSK_DS8K_IBM_LSARRAY](
	[FATHER_EQUIPMENT] [nvarchar](max) NULL,
	[TIMESTAMP] [nvarchar](max) NULL,
	[ARRAY] [nvarchar](max) NULL,
	[STATE] [nvarchar](max) NULL,
	[DATA] [nvarchar](max) NULL,
	[RAIDTYPE] [nvarchar](max) NULL,
	[ARSITE] [nvarchar](max) NULL,
	[RANK] [nvarchar](max) NULL,
	[DA_PAIR] [nvarchar](max) NULL,
	[DDMCAP_10POW9B] [nvarchar](max) NULL,
	[DISKCLASS] [nvarchar](max) NULL,
	[ENCRYPT] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
Import-Dbacsv -SqlInstance SQLCSRV04\SQL2017 -Database Storage -Schema staging -Table DSK_DS8K_IBM_LSARRAY -Path C:\temp\storage\test.txt -Delimiter ";" -KeepNulls

Expected Behavior

It should import the data

Actual Behavior

Error:

WARNING: [16:16:57][Import-DbaCsv] Failure | Value cannot be null.
Parameter name: connection

Without specifying -KeepNulls it works without issues.

Environmental data

Name                           Value
----                           -----
PSVersion                      5.1.17134.407
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.407
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Microsoft SQL Server 2017 (RTM-CU11) (KB4462262) - 14.0.3038.14 (X64)   Sep 14 2018 13:53:44   Copyright (C) 2017 Microsoft Corporation  Developer Edition (64-bit) on Windows Server 2016 Standard 10.0 <X64> (Build 14393: ) (Hypervisor) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions