We have .sql files that test our ETL. Manual execution in SSMS is with SQLCMD
enabled and results are written to flat file. This is done via :out (SQLCMD command) followed by the desired filepath location. We now are working to automate the execution of these within SSIS and have hit a snag. How do we enable SQLCMD
in SSIS as we loop through the .sql
files?
Further clarification: our .sql file is written as
:out \\(desired file destination folder and file name).txt
sel top 10 a,b,c from table A
sel top 10 d,e,f,x,t from table B
sel top 10 a,b,g,q,o,p from table C
When this is run from SSMS it generates the result to the destination stacking the answers one after the other. our intention is to use this .sql file run from VisualStudio (SSIS). We tried to use the .sql file as storproc but the result gives the answer of the first sel. while using Script Task. The execute SQL task (with full result set) does not produce the file at all because the answer is stored as variable. any suggestion on this please?