Can I specify an input sql file with bcp?
As far as I'm concerned the BCP utility only supports Transact-SQL queries directly written to the command line. Ex:
bcp "SELECT Name FROM AdventureWorks.Sales.Currency" queryout Currency.Name.dat -T -c
According to its reference the "-i" option:
Specifies the name of a response file, containing the responses to the command prompt questions for each data field when a bulk copy is being performed using interactive mode (-n, -c, -w, or -N not specified).
Notice that it differs from the sqlcmd Utility "-i" option:
Identifies the file that contains a batch of SQL statements or stored procedures. Multiple files may be specified that will be read and processed in order (...)
How to run a .sql file using bcp in SQL Server
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
Is there any way we can resume file load from nth line in a bcp utility instead of loading the file from the beginning?
Yes. BCP has a -F parameter that will let you specify a 1-based offset. So, if you wanted to skip the first 1000 rows, you'd do:
bcp yourdb.dbo.yourtable in yourfile.bcp -F 1001 ...
Related Topics
How to Execute Different Select Statements Based on a Case
Sql Server Table Locks in Long Query - Solution: Nolock
How to Select Row with Max Value When Duplicate Rows Exist in SQL Server
Sql Server Equivalent of Postgresql Distinct on ()
How to Execute SQL Statements in Command Prompt (Cmd)
Elegant Way of Handling Postgresql Exceptions
Why Sum(Null) Is Not 0 in Oracle
How to Drop a Column with Object Dependencies in SQL Server 2008
What Is Srid 0 for Geometry Columns
Sql Query - Limiting Query Results
Generate Create Scripts for a List of Indexes
What Is The Meaning of Kanatype Sensitive Ks and Width Sensitive
How to Perform a Cross Join or Cartesian Product in Excel
How to Concatenate Multiple Rows' Fields in a Sap Hana Table