dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


This command migrates custom errors (user defined messages) from one SQL Server to another. By default, all custom errors are copied. The -CustomErrors parameter is autopopulated for command-line completion and can be used to copy only specific custom errors.

If the custom error already exists on the destination, it will be skipped unless -Force is specified. Force drops and recreates the custom error.


To copy all server custom errors from sqlserver2014a to sqlcluster, using integrated (Windows) authentication. If custom errors with the same name exist on sqlcluster, they will be skipped.


To copy a single custom error, the custom error with ID number 6000 from sqlserver2014a to sqlcluster, using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If a custom error with the same name exists on sqlcluster, it will be updated because -Force was used.


To see what would happen if the command were executed using force


* Interesting fact, if you drop the us_english version, all the other languages will be dropped for that specific ID as well. Also, the us_english version must be created first.


From PowerShell, execute Get-Help Copy-DbaCustomError -Detailed for more information on this function.

Source Code

Want to see the source code? View Copy-DbaCustomError.ps1 on GitHub

Related commands