Here's my scenario.
I have a few different stored procedures to make. They will each perform a unique task, but based on a rather similar parameters pattern.
To avoid writing the (almost) same code over and over again, I would like to use a T4 template that will work using just a few variable input to generate the "upper" section of a procedure (variable declaration and initialization, mainly).
What I'd like to do now is to use the T4 template's output file as "part one" of the procedure, and another file as "part two". Kinda like the "partial class" feature found in other languages such as C# but with a sequencial order.
Here's how I'd like it:
File 1:
CREATE PROC blabla
@param1 INT,
@param2 VARCHAR(50)
AS
DECLARE @someConditionMet = 0
IF (@param1 > 0)
BEGIN
-- Imagine some recurrent pattern here
END
File 2:
IF @someConditionMet = 1
BEGIN
-- Elaborate, procedure-unique code here
END
RETURN 0
Is there any way to do that? By following a file naming convention in the likes of "Procedure_#.sql" where "#" would be used to determine the order in which the SSDT engine must concatenate the code, or some special SSDT syntax for file includes?
Additional note: I am aware that I could simply put the whole code for each procedure in a dedicated TT file, but that would mean losing Visual Studio's SQL editor features such as Intellisense. Not an acceptable solution.
There isn't a way to merge code like this, deploy scripts can use ":r file name" imports from the sqlcmd bits.
How many/how often do they change? It sounds like a one off operation taut you would want to do then just save the procs in the project??