I need to write a batch file that is piping the output of SQLCMD to an application that will modify the tables on which the SQLCMD is reading from:
sqlcmd -E -h-1 -S . -d Database -i Script.sql|ModifyApplication.exe
Unfortunately the command from above does run into a dead lock. So I modified the batch script to look like that:
sqlcmd -E -h-1 -S . -d Database -i Script.sql>tmp.txt
type tmp.txt|ModifyApplication.exe
This works – but it’s ugly because it needs to write to the file system and if for some reason the SQLCMD fails to write the file then the old file from the previous run will be piped into ModifyApplication.exe.
It would be ideal if I could just buffer all the data from the sqlcmd into the memory before piping it to ModifyApplication.exe like so:
sqlcmd -E -h-1 -S . -d Database -i Script.sql|Buffer.exe|ModifyApplication.exe
Is there a “Buffer.exe”-like command in windows?
As nos suggested I wrote one: