I have a stored procedure with a parameter of type nvarchar(max). And I need to call it in PowerShell.
// $s can be a long string with all kind of charaters, ', new line, etc.
Invoke-Sqlcmd -ServerInstance Server "exec MyProc '$s'"
However, the above calling doesn't work well when $s has ' (I know I can handle this case by replacing '' to '' but) or \n\r, etc. Also it has the risk of SQL injection.
Is it a way to invoke the stored without string concatenation?