il faut du texte aussi ici pour expliquer le script
select * from table1| function Beep { | |
| param ( | |
| [string]$slqInstance, | |
| [int32]$spid | |
| ) | |
| while ($true) { | |
| $a = Invoke-DbaQuery -SqlInstance $SqlInstance -Query "exec sp_who2 $spid" | |
| if ($a.Command -ne 'KILLED/ROLLBACK') { | |
| 1..3 | %{ [System.Console]::Beep((100 * $_ + 200), 300)} # 3 beeps with different pitch | |
| } else { |
| # Remove empty lines (raw text) | |
| -replace '(?m)^(?:[\t ]*(?:\r?\n|\r))+' | |
| # Add a GO line every 5000 lines (in a SQL script file) | |
| -replace '((INSERT.*\r\n){5000})', "`$1GO`r`n" |
| # Powershell Functions for MS Access :) | |
| # Here are several functions that cover tasks I tend to do most often in Access (hopefully more to come soon). These are mostly | |
| # just wrappers around Access VBA methods, but this helps me avoid constant googling every time I need to do something in Access. | |
| # example usage is provided at the bottom of the script | |
| # Import CSV file into MS Access database | |
| # office vba documentation: https://docs.microsoft.com/en-us/office/vba/api/access.docmd.transferspreadsheet | |
| function Import-MsAccessCsv |
| function Get-DbaMaintenanceSolutionVersion { | |
| param( | |
| $SqlInstance, | |
| $Database = 'master' | |
| ) | |
| $query = "select object_definition(object_id) as SQLtxt from $Database.sys.procedures where name = 'DatabaseIntegrityCheck'" | |
| foreach ($sql in $SqlInstance) { | |
| $sp = Get-DbaDbStoredProcedure -SqlInstance $sql -Database $Database -Name DatabaseIntegrityCheck | |
| if ($sp) { | |
| $version = if ($sp.TextBody -match '--// Version: ([\d-]+ [\d\:]+)') { |
| Find-DbaCommand | Select-Object -ExpandProperty Tags -Unique -ErrorAction SilentlyContinue | Sort-Object |
| Function Copy-IfNotPresent { | |
| <# | |
| .SYNOPSIS | |
| Copy file only if not present at destination. | |
| .DESCRIPTION | |
| This is a one file at a time call. It's not meant to replace complex call like ROBOCOPY. | |
| Destination can be a file or folder. | |
| If it's a folder, you can use -Container to force Folder creation when not exists. | |
| If it's a file, you can provide a different name. | |
| .LINK |
| -- Change DB Owner, Compatibility Level and Page Verify | |
| use master | |
| go | |
| declare @cmptlevel int | |
| select @cmptlevel = compatibility_level from sys.databases where database_id = 1 | |
| select 'ALTER DATABASE ['+name+'] SET COMPATIBILITY_LEVEL = ' + cast(@cmptlevel as varchar) + ';' | |
| from sys.databases |