Closed OwainEsau closed 4 years ago
Hi, I have a pretty simple function that deletes a record from a table:
function executeDelete { param ($id, $table, $path, $database) $Query_Delete = "DELETE FROM $table WHERE CandDocID = $id" Invoke-SqlCmd2 -Query "Update JobCandidate SET CandDocID = NULL WHERE CandDocID = $id" -ServerInstance $ServerAddress -database $Database Invoke-SqlCmd2 -Query $Query_Delete -ServerInstance $ServerAddress -database $Database Write-Verbose "[REMOVED] $path " }
In most cases, this works fine but I am getting the following error somewhere near the dataset being deleted:
Incorrect syntax near '='. At C:\Program Files\WindowsPowerShell\Modules\DBATools\0.9.487\allcommands.ps1:60363 char:21 + [void]$da.fill($ds) + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], SqlException + FullyQualifiedErrorId : SqlException
I can't seem to just set the error action to SilentlyContinue either
you should use sqlparameters and placeholders to be sure your query is always escaped correctly.
Hi, I have a pretty simple function that deletes a record from a table:
In most cases, this works fine but I am getting the following error somewhere near the dataset being deleted:
I can't seem to just set the error action to SilentlyContinue either