Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: add substitution of SQLCMD variables to QuickDeploy #21

Open
sryabkov opened this issue Nov 10, 2017 · 0 comments
Open

Suggestion: add substitution of SQLCMD variables to QuickDeploy #21

sryabkov opened this issue Nov 10, 2017 · 0 comments

Comments

@sryabkov
Copy link

I was looking for a VS extension that does two things: 1) replaces CREATEs with ALTERs in individual artifact definitions (stored procedures, functions and views) in SSDT database projects and 2) does SQLCMD variable substitution. I found your SSDT-DevPack and it looks like QuickDeploy already does half of what I need. I particularly like Quick Deploy To Clipboard - very nice!

Would you be open to adding SQLCMD variable substitution to Quick Deploy? E.g., if there is a SQLCMD variable defined in the project and a stored procedure, function or a view references it, Quick Deploy would substitute it with a default value. Here is an example:

Let's say I have an SSDT database project with a database reference and the following stored procedure:

CREATE PROCEDURE [dbo].[spProcedure1]
AS
    SELECT * FROM [$(SomeOtherDb)].dbo.Table1

If I run the current version of Quick Deploy To Clipboard on this SP, I get

if object_id('[dbo].[spProcedure1]') is null
begin
 execute sp_executeSql N' create procedure [dbo].[spProcedure1] as select 1;';
end
GO
alter PROCEDURE [dbo].[spProcedure1]
AS
    SELECT * FROM [$(SomeOtherDb)].dbo.Table1
GO

What I would like to get is

if object_id('[dbo].[spProcedure1]') is null
begin
 execute sp_executeSql N' create procedure [dbo].[spProcedure1] as select 1;';
end
GO
alter PROCEDURE [dbo].[spProcedure1]
AS
    SELECT * FROM SomeOtherDb.dbo.Table1
GO

(notice the difference in the FROM part of the SELECT statement)

The SQLCMD variable substitution should not be very complicated to implement as the default values for SQLCMD variables are stored in the database project:

image

They are stored in the .sqlproj file in the following section:

  <ItemGroup>
    <SqlCmdVariable Include="SomeOtherDb">
      <DefaultValue>SomeOtherDb</DefaultValue>
      <Value>$(SqlCmdVar__2)</Value>
    </SqlCmdVariable>
  </ItemGroup>

@GoEddie Do you have any interest in implementing this functionality? If not, or if you don't have the time, would you accept a PR implementing this functionality, if there were one? What requirements would you have for such a PR?

Thanks,
Sergei

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant