SQLTeam.com | Weblogs | Forums

Changing variable values when deploying scripts to prod

Greetings,

When auto deploying (via powershell) what would be the best option to specify passwords and specific server names based on environment vars or Maybe prompt the person deploying it?

EXEC master.dbo.sp_addlinkedserver @server = N'BISERVER', 
@srvproduct=N'', @provider=N'SQLNCLI', @datasrc='PLEASE_PROVIDE_BISERVER'

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'BISERVER',@useself=N'False',
@locallogin=NULL,
@rmtuser=N'PLEASE_PROVIDE_USER',@rmtpassword='PLEASE_PROVIDE_PASSWORD'
GO

If you use powershell I would use named parameters in powershell:

How to Use Parameters in PowerShell Part I - Simple Talk (red-gate.com)

1 Like