Search code examples
sql-serverwindowspowershellt-sqlperfmon

relog not working via t-sql xp_commandshell but same command working on command prompt


Below command is working fine on command prompt and ps but giving error via t-sql, is there any solution around this ?

set @command=  'relog'+' "'+@loctoreaddata+'"'+ '-cf '+ '"'+'N:\Perfcounterlist\'+'test.txt'+'"'+' -f SQL -o SQL:Perfdata!SQLDEMO1'
        exec    xp_cmdshell @command

Below error in sql Error: To relog multiple files all files must be in binary format.

Below in win events

Call to SQLAllocConnect failed with [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.

out put of select @command for reference

relog "N:\PerfMonAutomation\MasterActive.blg"-cf "N:\Perfcounterlist\test.txt" -f SQL -o SQL:Perfdata!SQLDEMO1

Solution

  • "Error: To relog multiple files all files must be in binary format" All this means is that the files you're working with are different kinds, and they don't get along with each other. If a file is created and something changes within, it gets updated. Even when saved as the same type of file (especially .CSV files), the binary code changes. Find what's being changed between file creation and your script, and you'll find the issue. For example, CSV file opened with excel, and then saved as CSV file again (warning: some features in your workbook might be lost if you save it as a CSV).