Search code examples
sql-serverbatch-filebcp

How to run a .sql file using bcp in SQL Server


I am new to handling SQL Server bulk export. I have a batch file in which I have written some code to execute specific .sql files at regular intervals and save the output into an excel sheet. I have done this using sqlcmd. I want to use bcp to do the same. Any help on this issue is much appreciated.


Solution

  • use -s "|" with sqlcmd. That should allow you to out-put the data with fields separated by a tab.

    -s is for column separator.

    See sqlcmd Utility