SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Jobs in PoSh to Create a Load

I saw this from Argenis Fernandez, and thought it was wonderful.

1..128 | % { start-job -name ‘job name’ -scriptblock { & sqlcmd -S instanceName -U sa -P ‘iLovePoSh’ -i /home/username/test.sql } }

Create 128 threads, each running a background job in PowerShell to connect to an instance and run a script file.

Start-Job is used to begin a job, and then you can get information from Get-Job and use Stop-Job to turn things off.

Very cool. Looking forward to trying to use this in a demo and make things happen.

The Voice of the DBA

Steve Jones is the editor of SQLServerCentral.com and visits a wide variety of data related topics in his daily editorial. Steve has spent years working as a DBA and general purpose Windows administrator, primarily working with SQL Server since it was ported from Sybase in 1990. You can follow Steve on Twitter at twitter.com/way0utwest

Comments

Leave a comment on the original post [voiceofthedba.com, opens in a new window]

Loading comments...