# Array of ListIDs to be updated $listIDs = @( "20", "21", "22" ) # Define the DSN name #$dsnName = "QuickBooks Online Data" $dsnName = "QuickBooks Data" # Add your DSN name here #$dsnName = "QuickBooks Online Data" # Define the DSN name #$dsnName = "QuickBooks Data" #$dsnName = "QuickBooks Online Data" # Add your DSN name here $dsnName = "Your DSN Name" Write-Output "Connecting to $dsnName" # Build connection string $connStr = "DSN=$dsnName;" # Create a new ODBC connection $conn = New-Object System.Data.Odbc.OdbcConnection $conn.ConnectionString = $connStr try { # Open the connection $conn.Open() Write-Output "Connected to DSN: $dsnName" Write-Output "Updating records." foreach ($listID in $listIDs) { #Prepare the SQL statement # Either use ifnull or use the 2nd SQL statement $sql = @" UPDATE Account SET Description = {fn IFNULL(Description, '')} + '.' WHERE ListID = '$listID' "@ # Prepare the SQL statement $sql = @" UPDATE Account SET Description = Description + '.' WHERE ListID = '$listID' "@ Write-Output "SQL statement: $sql" # Create command $cmd = $conn.CreateCommand() $cmd.CommandText = $sql try { # Execute the update $rowsAffected = $cmd.ExecuteNonQuery() Write-Output "Updated ListID: $listID ($rowsAffected rows affected)" } catch { Write-Error "Error updating ListID: $listID - $_" } } } catch { Write-Error "Could not connect to ODBC DSN: $dsnName - $_" } finally { # Close the connection if ($conn.State -eq 'Open') { $conn.Close() Write-Output "Connection closed." } }