Home Forums Programming Powershell Powershell and Excel and SQL Server RE: Powershell and Excel and SQL Server

  • Here's some feedback:

    I've found that the code below is considerably faster than my previous RBAR-CBAC solution -- although I think that's what's happening in the background of the where clause.

    $Rows = $UserWorksheet.Range("A2:H$LastRow").Cells | ?{$_.Interior.ColorIndex -ne -4142} | Sort-Object -Property row -Unique | select row

    I have 8 columns in my table, 7 of which need to be searched for ColorIndex, and as soon as I find one -ne -4142 field on a row, I can stop looking at that row. So I tried to iterate through the columns where rowid not in changed rows. Bad idea: took 7 times longer to go through 51 rows of data than the above code.