diff --git a/Public/ConvertFrom-ExcelToSQLInsert.ps1 b/Public/ConvertFrom-ExcelToSQLInsert.ps1 index b468d8b..858544e 100644 --- a/Public/ConvertFrom-ExcelToSQLInsert.ps1 +++ b/Public/ConvertFrom-ExcelToSQLInsert.ps1 @@ -16,12 +16,15 @@ function ConvertFrom-ExcelToSQLInsert { [switch]$NoHeader, [switch]$DataOnly, [switch]$ConvertEmptyStringsToNull, - [switch]$UseMsSqlSyntax + [switch]$UseMsSqlSyntax, + [Parameter(Mandatory = $false)] + $SingleQuoteStyle ) $null = $PSBoundParameters.Remove('TableName') $null = $PSBoundParameters.Remove('ConvertEmptyStringsToNull') $null = $PSBoundParameters.Remove('UseMsSqlSyntax') + $null = $PSBoundParameters.Remove('SingleQuoteStyle') $params = @{} + $PSBoundParameters @@ -38,11 +41,16 @@ function ConvertFrom-ExcelToSQLInsert { 'NULL' } else { - "'" + $record.$propertyName + "'" + if ( $SingleQuoteStyle ) { + "'" + $record.$propertyName.ToString().Replace("'",${SingleQuoteStyle}) + "'" + } + else { + "'" + $record.$propertyName + "'" + } } } $targetValues = ($values -join ", ") "INSERT INTO {0} ({1}) Values({2});" -f $TableName, $ColumnNames, $targetValues } -} \ No newline at end of file +}