mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Added UseMSSQLSyntax to code gen INSERT INTO format
This commit is contained in:
@@ -103,11 +103,13 @@ function ConvertFrom-ExcelToSQLInsert {
|
||||
[string[]]$Header,
|
||||
[switch]$NoHeader,
|
||||
[switch]$DataOnly,
|
||||
[switch]$ConvertEmptyStringsToNull
|
||||
[switch]$ConvertEmptyStringsToNull,
|
||||
[switch]$UseMSSQLSyntax
|
||||
)
|
||||
|
||||
$null = $PSBoundParameters.Remove('TableName')
|
||||
$null = $PSBoundParameters.Remove('ConvertEmptyStringsToNull')
|
||||
$null = $PSBoundParameters.Remove('UseMSSQLSyntax')
|
||||
|
||||
$params = @{} + $PSBoundParameters
|
||||
|
||||
@@ -115,6 +117,10 @@ function ConvertFrom-ExcelToSQLInsert {
|
||||
param($propertyNames, $record)
|
||||
|
||||
$ColumnNames = "'" + ($PropertyNames -join "', '") + "'"
|
||||
if($UseMSSQLSyntax) {
|
||||
$ColumnNames = "[" + ($PropertyNames -join "], [") + "]"
|
||||
}
|
||||
|
||||
$values = foreach ($propertyName in $PropertyNames) {
|
||||
if ($ConvertEmptyStringsToNull.IsPresent -and [string]::IsNullOrEmpty($record.$propertyName)) {
|
||||
'NULL'
|
||||
|
||||
Reference in New Issue
Block a user