Skip to content

Instantly share code, notes, and snippets.

@MikeFal
Created November 10, 2015 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeFal/244247c679a27fe94895 to your computer and use it in GitHub Desktop.
Save MikeFal/244247c679a27fe94895 to your computer and use it in GitHub Desktop.
Clustered Guid Insert Code
$set = 'abcdefghijklmnopqrstuvwxyz'.ToCharArray()
$rowcount = 2000
$tables = @('GUIDTest','NonGuidTest','SeqGUIDTest')
foreach($table in $tables){
$Start = Get-Date
for($row=0;$row -lt $rowcount; $row++){
$orgname = ''
for($char=0;$char -lt 20;$char ++){
$orgname += $set | Get-Random
}
Invoke-Sqlcmd -Database dummy -Query "INSERT INTO $table(orgname) VALUES('$orgname');"
}
$time = ((Get-Date) - $Start).Seconds
Write-Host -ForegroundColor Cyan "$table Insert: $rowcount rows, $time seconds"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment