I need to "inject" a file that contains a T-SQL procedure into many T-SQL scripts. Something along the lines of :
EXECUTE '../CSV_From_Sql.sql', #CsvFileCreator <other parameters>
where #CsvFileCreator is the entry point (i.e. the procedure name) in '../CSV_From_Sql.sql'.
Note that results produced by #CsvFileCreator must be within (accessable from) the scope/namespace of the invoking script.
At the moment I am not allowed to create stored procedures. To meet the scoping requirements #CsvFileCreator must be "injected" (copied) into each script. This has to be done in a way that allows #CsvFileCreator to be simultaneously updated in all queries (and eventually converted to a stored procedure).
The desired effect is, in essence, an "insert text here" operation (i.e. replace the EXECUTE statement with the contents of the file). Which should be extremely simple to do except that Microsoft's documentation does not seem to allow for this.
Some context: In my case SQL server is being used as the back end to a python 3.X GUI report generator. End users have absolutely no access to the SQL code and there's no opportunity for injection. All users can do is make their choices (via checkboxes, spinboxes, etc) and press a "Create Reports" button (this causes python to invoke SQL server). Also the very nature of the app means it will NEVER be on a network that is connected to the outside world.
For reasons that I will not get into, only "pure" T-Sql commands can be used and the use of any type of manual operation (e.g. use of tools like SSMS, bcp, sqlcmd, etc.) is not possible. In my case I could automatically insert this "boilerplate procedure" before invoking each query.
Is there a pure T-SQL way to get the "execute file" or "copy file" effect?