Search code examples
sqlpowershellbatch-filesqlcmd

SQLCMD , 'tee' is not recognized as an internal or external command


I've fetchDb.bat file that calls many .sql files to upgrade the database to last version

this is the command used to execute .Sql File content

sqlcmd %Sqlinstance% -d DataBase -i "fileName.sql" | tee "FileNameOutput.txt"

but this message Always appear for me 'tee' is not recognized as an internal or external command , operable program or batch file.


Solution

  • tee ( Tee-Object ) is cmdlet which is supported in powershell. so you have to use powershell for this or you can use below command to save output to file in bat

     COMMAND >> Filename
    

    in your case :

    sqlcmd %Sqlinstance% -d DataBase -i "fileName.sql" >> "FileNameOutput.txt"