How can I skip or say "error" on SQL server when the data does not match with data type?
such as ID has nchar(2) on SQL server and I have csv file that one of data is '1234' for ID.
How can I have error sign or error report for that data in SQL server.
It is ok that I can have separate excel file about all the errors.
I just want to know which data got error.
And make the script without stopping even there is an error.
Here is my script
$today = (get-date).Date
$DataImport = Import-Csv -Path (Get-ChildItem filename | where { $_.CreationTime.Date -eq $today } )
$DataTable = Out-DataTable -InputObject $DataImport
write-DataTable -serverInstance servername -Database DBname -TableName Table name -Data $DataTable
Functions Out-DataTable and Write-DataTable have been defined.