Handling Nested Sql scripts possible with RedGate ?

bahranibahrani Posts: 4
Hi,

I have one scenario wherein i have one sql script (Main.sql) to which i pass some arguments and execute the sql script using SQLCMD command
(e.g.
SQLCMD -S %1 -U %2 -P %3 -d %4 -i Main.sql -v Argument1="%4" -v Argument2="%5" -v Argument3="%4" -v filepath="%CD%" -o sql_Log_Module.txt)

This sql script (Main.sql) internally calls some more sql scripts and these internal nested scripts use the parameters passed to the main script i.e., "Main.sql" (mentioned above)

Internal scripts also have the stored procedures which gets executed

Currently we execute sql script (Main.sql) directly in batch file with the help of SQLCMD command, but we are thinking to use Red Gate (SQL Packager) instead of SQLCMD in batch file

It will be great if you provide some inputs on whether this can be done with the help of RedGate or not, i mean to say whether this is possible with the help of RedGate or not

Thanks in advance,
Ishant

Comments

  • Unfortunately I was unable to find previous instances where SQL Packager was used in this manner, so I can't say for certain that it will work.
    One thing that concerns me is how do you intend to pass arguments to SQL packager since that is not supported. I suppose if the arguments were supplied within the script itself it may work.
    I would suggest you try it for yourself, to see if the tool for work for you in this use case.
    Manfred Castro
    Product Support
    Red Gate Software
  • Thanks for your inputs

    Yes regarding arguments while generating .exe for .sql script I was trying to pass arguments to SQL Packager with .sql script itself but as you rightly mentioned i was not able to do so.

    So i thought lets generate the .exe first and then there might be some provision to pass arguments to the .exe which gets generated with the help of SQL Packager (with .sql script as input to SQL Packager) but later on after obtaining the .exe from SQL Packager i realised that we can pass only some predefined fixed arguments to .exe (like servername, databasename, username, password, makedatabase or makeupgrade, presql, postsql)

    Also the requirement is such that the values of the arguments gets generated at runtime based on the user inputs and hence values of arguments are not fixed so keeping arguments internally within the script with fixed values will not satify our requirement

    So what i understand from your inputs and with some hands on is that we cannot handle the scenario with the SQL packager wherein .sql scripts needs some arguments as inputs, right ?

    Correct me if i am wrong

    Thanks,
    Ishant
  • I don't believe that this particular tool will work in your use case.
    You may want to check out our other product the SQL Comparison SDK.
    http://www.red-gate.com/products/sql-de ... rison-sdk/
    This tool allows you to use SQL Packagers API to create your own application.
    Manfred Castro
    Product Support
    Red Gate Software
Sign In or Register to comment.