How to display the number of rows affected in sql text file

I am using a batch file to run SQL statements from another file. How to register a result or error message in a text file in the same folder. Here's what I did: "

@echo off
sqlcmd.exe -S "(localdb)\v11.0" -i C:\SQLBatch\CreateLinkServer.sql -o C:\SQLBatchCreateLinkServer.txt

The log file (SQLBatchCreateLinkServer.txt) contains only "Modified database context for" master "." How to make a package write all the data in a log, for example no. affected rows and which query is being called.

thank

+4
source share
1 answer

Parfait's suggestion helped solve the problem.

I had it

@echo off sqlcmd.exe -S "(localdb)\v11.0" -i C:\SQLBatch\CreateLinkServer.sql -o C:\SQLBatchCreateLinkServer.txt

instead

@echo off sqlcmd.exe -S "(localdb)\v11.0" -i C:\SQLBatch\CreateLinkServer.sql -o C:\SQLBatch\CreateLinkServer.txt

therefore, the invoice is not written to the specified file.

, SQLBatchCreateLinkServer.txt, CreateLinkServer.txt SQLBatch

0

Source: https://habr.com/ru/post/1688723/


All Articles