When to use BCP to reference a stored procedure?

When to use BCP to reference a stored procedure?

The query can reference a stored procedure as long as all tables referenced inside the stored procedure exist prior to executing the bcp statement. For example, if the stored procedure generates a temp table, the bcp statement fails because the temp table is available only at run time and not at statement execution time.

Is the BCP utility compatible with SQL Server?

In SQL Server, the bcp utility supports native data files compatible with SQL Server versions starting with SQL Server 2000 (8.x) and later. Computed Columns and timestamp Columns Values in the data file being imported for computed or timestamp columns are ignored, and SQL Server automatically assigns values.

What happens if you do not have a format file for BCP?

If you use bcp to back up your data, create a format file to record the data format. bcp data files do not include any schema or format information, so if a table or view is dropped and you do not have a format file, you may be unable to import the data.

How to check the version of BCP in SQL Server?

To check the BCP version execute bcp /v command and confirm that 15.0

When does a BCP statement fail in SQL?

For example, if the stored procedure generates a temp table, the bcp statement fails because the temp table is available only at run time and not at statement execution time. In this case, consider inserting the results of the stored procedure into a table and then use bcp to copy the data from the table into a data file.

How to export a SP result in BCP?

I’m trying to use BCP to export a SP result to a text file using this query: The output of this query is telling this error: Error = [Microsoft] [SQL Server Native Client 10.0] [SQL Server]Incorrect syntax near the keyword ‘where’. even thought I’m sure that the stored procedure “usp_Contract_SelectByEmpId” is working correctly.