driftme.ps1
lets you drift a database by creating a column with the pattern driftme-tablename-GUID
on a specific table. If the column already exists it renames it by generating a new GUID
The script comes with some default values that you might want to change:
$server="yourservername"
$sqlServerVersion="sql2014"
$dbToDrift="yourdbtodrift"
$tableToDrift="yourtabletodrift"
This is the list of variables that you can override:
-server
: the server where the database is.-sqlversion
: the version of the sql server (sql2012
orsql2014
).-dbToDrift
: the database to drift.-tableToDrift
: the table to drift.
PS C:\> C:\driftme.ps1
Drift Me!
Running in \sql\yourservername\sql2014\databases\yourdbtodrift
This script will perform a drift on database: yourdbtodrift in table: yourtabletodrift
WARNING: Using provider context. Server = yourservername\sql2014, Database = yourdbtodrift.
WARNING: Using provider context. Server = yourservername\sql2014, Database = yourdbtodrift.
Drift successfull
On table yourdbtodrift.dbo.yourtabletodrift added column '[driftme-yourtabletodrift-95c59155-4c48-49d8-a298-7cbe2d1ca953]'
Drift successfull
On table yourdbtodrift.dbo.yourtabletodrift
Renamed column 'driftme-yourtabletodrift-95c59155-4c48-49d8-a298-7cbe
To 'driftme-yourtabletodrift-f4ba6538-b978-4ad9-897c-c111da300bed'
PS C:\> C:\driftme.ps1 -dbtodrift "anotherdb"
PS C:\> C:\driftme.ps1 -tabletodrift "anothertable" -dbtodrift "anotherdb"