SQLServerPSModule icon indicating copy to clipboard operation
SQLServerPSModule copied to clipboard

Write-SQLTableData - Progress action floods interactive consoles

Open DennisBergemann opened this issue 8 months ago • 1 comments

The progress of the Write-SQLTableData function floods interactive consoles and memory. On PS5 it’s not possible to suppress the progress.

Or may be a way we don’t know?

DennisBergemann avatar Jun 14 '25 18:06 DennisBergemann

Hi @DennisBergemann,

I would suggest a couple of options:

  1. Feed the cmdlet either a DataTable or a DataSet object
  2. Before running the cmdlet, consider setting $ProgressPreference = 'SilentlyContinue'

For (1), that a generally good idea [when possible]. For example, avoid

# Insert
$LongArray = 1..1000
$LongArray | Write-SQLTableData -ServerInstance SQL3 -DatabaseName tempdb -TrustServerCertificate -SchemaName dbo -TableName T1 -Force

instead use either

$LongArray = 1..1000
# Note the little comma before the array
,$LongArray | Write-SQLTableData -ServerInstance SQLS3 -DatabaseName tempdb -TrustServerCertificate -SchemaName dbo -TableName T1 -Force

or

$LongArray = 1..1000
# Avoid the pipeline and use -InputData
Write-SQLTableData -ServerInstance SQL3 -DatabaseName tempdb -TrustServerCertificate -SchemaName dbo -TableName T1 -Force -InputData $LongArray 

If you have any more specific example, where neither (1) nor (2) help, let me know...

Matteo-T avatar Jun 15 '25 10:06 Matteo-T