How to pass the environment name in the SQL script?

Khaja Mohammad (RCG) 0 Reputation points
2023-07-21T16:11:33.91+00:00

We have 2 environments stage and prod

reference-{env}-central - is the user name

azure-{env}-central.database.windows.net; - is the server name.

IF EXISTS (SELECT * FROM sys.server_principals WHERE NAME = 'reference-{env}-central')

DROP LOGIN [reference-{env}-central] :azure-{env}-central.database.windows.net;

I want to know how to pass the environment name stage and prod whereever {env} is there becuase when i point to stage environment in the Azure pipeline task properties. It should select the name stage in place of {env} and drop the login and when pointed to prod it should select the name dev and drop the login

Azure SQL Database
Microsoft Security Microsoft Entra Microsoft Entra ID
SQL Server Other
{count} votes

1 answer

Sort by: Most helpful
  1. Vahid Ghafarpour 23,385 Reputation points Volunteer Moderator
    2023-07-21T18:35:35.76+00:00

    You can use Azure DevOps pipeline variables, and they define at the pipeline level or within specific tasks, allowing you to customize their values based on your deploying environment.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.