-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
With something like this:
CREATE TABLE [dbo].[TestTable1](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](64) NOT NULL,
[ChangeDateTime] [datetime] NOT NULL,
[Category] [nvarchar](64) NOT NULL
CONSTRAINT [PK_TestTable1] PRIMARY KEY CLUSTERED
(
[Id] ASC
) ON [PRIMARY]
)
ALTER TABLE [dbo].[TestTable1] ADD CONSTRAINT [DF_TestTable_ChangeDateTime] DEFAULT (getdate()) FOR [ChangeDateTime]
GO
In SQL, I can do this:
INSERT INTO [dbo].[TestTable1]
(
[Name],
[Category]
)
VALUES
(
'MyName1'
,'Blue'
)
GO
I expect (perhaps with an additional parameter, CheckConstraints?) to be able to do this:
$PSObj = [PSCustomObject]@{
Id = ''
Name = 'FromPwsh'
ChangeDateTime = ''
Category = 'Red'
}
Write-SqlTableData -InputData $PSObj -ServerInstance $SqlServer -DatabaseName $DatabaseName -TableName $TableName -SchemaName $SchemaName
but that fails with
Write-SqlTableData : The given value '' of type String from the data source cannot be converted to type datetime for Column 2 [ChangeDateTime] Row 1.
Metadata
Metadata
Assignees
Labels
No labels