crimdon / SQLToolkit

An Extension for Azure DevOps Server
MIT License
17 stars 14 forks source link

Pass parameters to SQL scripts #74

Closed matthiasguentert closed 4 years ago

matthiasguentert commented 4 years ago

Hi

We are using the "Run Sql Scripts" task on a release pipeline on our on-premise Azure Devops installation.

Now I would like to execute a script that contains the lines below. As you can see the script contains a hard-coded database name, which I would like to pass through via the task.

From a look at the source code I wasn't able to understand if this is possible and if so which variable I have to use inside my SQL script

So is this possible to pass through a database name? If so, which variable in which format would I have to use?

Thanks in advance.

/* Some magic required for CREATE ASSEMBLY */
ALTER DATABASE [FOO_DB] SET TRUSTWORTHY ON;
GO
sp_configure 'show advanced options', 1;
GO
RECONFIGURE; 
GO
sp_configure 'clr enabled', 1;
GO 
RECONFIGURE; 
GO 
crimdon commented 4 years ago

Its not currently written to allow that but I could see how that sort of thin could be done. If I get a chance, I'll have a go at adding that functionality in.

crimdon commented 4 years ago

I've implemented a sort of find and replace that should give you what you want

matthiasguentert commented 4 years ago

Nice! Thank you very much. Will look into it.