Share via

Run BCP command in sql server on linux

ASHISH SINGH 21 Reputation points
2021-08-11T15:28:47.623+00:00

Hi, For my client I'm using below command to create txt file from SQL table.
BCP "select * from dbo.VW_RETAILER order by [ContractID] ASC, [PersdonID] ASC, [SKUID] ASC, [SequenceNo] ASC" queryout "E:\Project\Retailer.txt" -T -c -t "\t" -a 65535 -d Tools_XYZ -S SALES_SERVER
Now Client want to use same command on their server but they are in the Linux environment.

Please assist how i can migrate this command in Linux OS !

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories


2 answers

Sort by: Most helpful
  1. Seeya Xi-MSFT 16,756 Reputation points
    2021-08-12T05:40:35.373+00:00

    Hi @ASHISH SINGH

    See this docs about bcp Utility: https://learn.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-ver15

    For using bcp on Linux, see Install sqlcmd and bcp on Linux.

    Best regards,
    Seeya


    If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

  2. Erland Sommarskog 134.7K Reputation points MVP Volunteer Moderator
    2021-08-11T21:21:45.377+00:00

    That command line should work on Linux as well, I think. Well, you obviously need to change the file path, to one that is valid on the Linux machine.

    And if integrated authentication is not working, you will need to replace -T with -U and -P for SQL authentication.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.