I am trying to do the following:
$Query = "SELECT [ScriptText] FROM MyDB.[MySchema].[DBScripts] where DBName = 'ABC' and ScriptName = '13-StoredProcedures.sql'"
$Script = Invoke-Sqlcmd -query $Query
Invoke-Sqlcmd -query $Script
I am getting an error message about some unclosed quotation mark and the value of the $script variable is truncated to around 8KB.
Even though the below query tells that the length of the string is 2543909 characters.
SELECT len([ScriptText]) FROM MyDB.[MySchema].[DBScripts] where DBName = 'ABC' and ScriptName = '13-StoredProcedures.sql'
Any idea how can I extract and execute the large script?
Nope, this is not about re-formatting or quotes. It is about the size of the text.
This solved my problem:
$Script = Invoke-Sqlcmd -query $Query -maxcharlength ([int]::MaxValue)
Powered by IDERA