BCP command executing in Putty

  • Hi Excerpts,

    I would require your help on below issue.I am new in MSSQL.

    My file is present in Linux server and SQL server is installed in Different server. Customer was excepting data from file (Which is present different server)  to MSSQL Table.  Can you please leave your comment on below questions

    1. My problem is we can't run BCP command in Linux system through putty ? 
    2. Customer was saying BCP is installed in Linux box but i couldn't able to find bcp in Linux ? How to find BCP is installed or not in LINUX box ?
    3. If bcp is possible through putty then what is the exact command ? Can you please give some example.

    Your help highly appreciated.

    Thanks,
    RR

  • satyainfosys - Tuesday, September 25, 2018 5:21 AM

    Hi Excerpts,

    I would require your help on below issue.I am new in MSSQL.

    My file is present in Linux server and SQL server is installed in Different server. Customer was excepting data from file (Which is present different server)  to MSSQL Table.  Can you please leave your comment on below questions

    1. My problem is we can't run BCP command in Linux system through putty ? 
    2. Customer was saying BCP is installed in Linux box but i couldn't able to find bcp in Linux ? How to find BCP is installed or not in LINUX box ?
    3. If bcp is possible through putty then what is the exact command ? Can you please give some example.

    Your help highly appreciated.

    Thanks,
    RR

    BCP is a SQL Server capability as opposed to a stand-alone program.   If you had SQL Server Management Studio installed on the Linux server, you could then "connect" to the other server that hosts SQL Server, and then be able to run the BCP command.   I don't know enough about the Linux version of SQL Server to know whether it has an equivalent to the Windows version of SQL Server Management Studio (aka SSMS).   I would prefer to believe that's the case, but I don't know for sure.   Someone else here will probably know.   In any case, you won't find BCP as an "installed program" anywhere on the Linux server, as again, it's a command you can specify when you are "connected" to a SQL Server using a query tool (which is what SSMS is).  If the Linux version of SQL Server has an SSMS equivalent, then just install that on the relevant Linux server and you can then connect and run such a command.   If I recall my limited Linux exposure, PUTTY is a remote connectivity tool, but I'm doubtful it could provide connectivity to SQL Server, as SQL Server doesn't quite work the way that PUTTY is designed to operate.   You might be better served by setting up the necessary BCP command as a SQL Agent Job directly on the SQL Server involved.    You can Google the BCP command syntax easily enough.  Hope that helps...

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • Hi Steve,

    Thanks for your  prompt response.

    If file is present in Linux server and SQL server is installed in different server , how to load data from Linux File to SQL SERVER ? Do you have document or link ? If yes please share me so that it will be very helpful. I tried to get it in google but no luck couldn't get what am looking.

    Note: Customer is not allowing to place the file where  MSSQL Server is running due security reason. i want to load data from (File present in Linux server) file and load into target SQLSERVER.

    I looking for steps what are the things need to follow.

    One more thing , What  is max size packet size in MSSQL ?

    Thanks
    RR

  • sgmunson - Tuesday, September 25, 2018 8:23 AM

    satyainfosys - Tuesday, September 25, 2018 5:21 AM

    Hi Excerpts,

    I would require your help on below issue.I am new in MSSQL.

    My file is present in Linux server and SQL server is installed in Different server. Customer was excepting data from file (Which is present different server)  to MSSQL Table.  Can you please leave your comment on below questions

    1. My problem is we can't run BCP command in Linux system through putty ? 
    2. Customer was saying BCP is installed in Linux box but i couldn't able to find bcp in Linux ? How to find BCP is installed or not in LINUX box ?
    3. If bcp is possible through putty then what is the exact command ? Can you please give some example.

    Your help highly appreciated.

    Thanks,
    RR

    BCP is a SQL Server capability as opposed to a stand-alone program.   If you had SQL Server Management Studio installed on the Linux server, you could then "connect" to the other server that hosts SQL Server, and then be able to run the BCP command.   I don't know enough about the Linux version of SQL Server to know whether it has an equivalent to the Windows version of SQL Server Management Studio (aka SSMS).   I would prefer to believe that's the case, but I don't know for sure.   Someone else here will probably know.   In any case, you won't find BCP as an "installed program" anywhere on the Linux server, as again, it's a command you can specify when you are "connected" to a SQL Server using a query tool (which is what SSMS is).  If the Linux version of SQL Server has an SSMS equivalent, then just install that on the relevant Linux server and you can then connect and run such a command.   If I recall my limited Linux exposure, PUTTY is a remote connectivity tool, but I'm doubtful it could provide connectivity to SQL Server, as SQL Server doesn't quite work the way that PUTTY is designed to operate.   You might be better served by setting up the necessary BCP command as a SQL Agent Job directly on the SQL Server involved.    You can Google the BCP command syntax easily enough.  Hope that helps...

    Actually, BCP is a stand-alone .exe program that just happens to be installed with SQL Server.  I don't know what the current licensing is but MS used to advertise that you could use it freely in your applications IF you copied all of the files that BCP entails.

    Agreed that you won't find it in installed programs because it needs no installation.  It's just an exe.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Hi Jeff,

    Thanks for your prompt response.

    If file is present in Linux server and SQL server is installed in different server , how to load data from Linux File to SQL SERVER ? Do you have document or link ? If yes please share me so that it will be very helpful. I tried to get it in google but no luck couldn't get what am looking.

    Note: Customer is not allowing to place the file where MSSQL Server is running due to security reason. i want to load data from (File present in Linux server) file and load into target SQLSERVER.

    I looking for steps what are the things need to follow.

    One more thing , What is max size packet size in MSSQL ?

    Thanks
    RR

  • satyainfosys - Tuesday, September 25, 2018 9:04 AM

    Hi Jeff,

    Thanks for your prompt response.

    If file is present in Linux server and SQL server is installed in different server , how to load data from Linux File to SQL SERVER ? Do you have document or link ? If yes please share me so that it will be very helpful. I tried to get it in google but no luck couldn't get what am looking.

    Note: Customer is not allowing to place the file where MSSQL Server is running due to security reason. i want to load data from (File present in Linux server) file and load into target SQLSERVER.

    I looking for steps what are the things need to follow.

    One more thing , What is max size packet size in MSSQL ?

    Thanks
    RR

    At some point you are going to have to have the file in someplace that is accessible to the system you are trying to run bcp on and the sql server.  Do you have some kind of a share that is accessible to both the linux server the file is on and the SQL Server?

  • satyainfosys - Tuesday, September 25, 2018 9:04 AM

    Hi Jeff,

    Thanks for your prompt response.

    If file is present in Linux server and SQL server is installed in different server , how to load data from Linux File to SQL SERVER ? Do you have document or link ? If yes please share me so that it will be very helpful. I tried to get it in google but no luck couldn't get what am looking.

    Note: Customer is not allowing to place the file where MSSQL Server is running due to security reason. i want to load data from (File present in Linux server) file and load into target SQLSERVER.

    I looking for steps what are the things need to follow.

    One more thing , What is max size packet size in MSSQL ?

    Thanks
    RR

    How about trying to read the Microsoft documentation?  https://docs.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-2017

  • I already gone through this link but couldn't understand because  I am beginner in MSSQL. Can you please give me syntax for import which include error file generation .

    One more thing , What is best packet size in MSSQL  in prod ?

  • @ZZartin :- if we don't have share path , is there way to do this import through bcp ?

  • satyainfosys - Tuesday, September 25, 2018 10:17 AM

    @ZZartin :- if we don't have share path , is there way to do this import through bcp ?

    Does the linux box have any connectivity to the SQL server at all(can you even ping it from the linux box)?  It looks like MS does have the bcp and sqlcmd tools available for linux, https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-2017 so if you can get those installed on your linux box and it can at least connect to the SQL Server that might work.

  • Yes, I am not able ping sql server in linux box.

    Can you please leave your comments on below queries.

    1.give me exact syntax for import command along with error file generation in case of record rejection through bcp. -- Give me which is working syntax in your experience. 
    2.  what  is  best packet size in MSSQL?
    3. we have to build 50 bcp import mappings with different users, can we setup any user can run any bcp import operation ? if yes how to setup ?

  • SATYA R - Tuesday, September 25, 2018 10:37 AM

    Yes, I am not able ping sql server in linux box.

    Can you please leave your comments on below queries.

    1.give me exact syntax for import command along with error file generation in case of record rejection through bcp. -- Give me which is working syntax in your experience. 
    2.  what  is  best packet size in MSSQL?
    3. we have to build 50 bcp import mappings with different users, can we setup any user can run any bcp import operation ? if yes how to setup ?

    Would you like us to do your work for you?  We can't tell you all that you want as 1) we are all volunteers giving of our own time, 2) we don't have access to your systems so we have no idea what the data looks like or what the tables look like that the data needs to go into, and 3) the best packet size is usually dependent on your network (speed and capacity).

    Hate to say it, but you need to try to do this.  Please, if you have problems (errors) come back and ask, being sure to provide full details of the problem.  If something doesn't make sense, come back and ask being sure to fully explain what you don't understand (expect x but getting y for example but with details).

  • Hi Lynn,
    Before implementation need to understand all areas to complete this task. Beacuse I am beginners in this technology. Sorry to trouble you. I ve to give concrete information to customer, that's y am clarifing all my doubts. Hope u understand
    I

  • SATYA R - Tuesday, September 25, 2018 11:21 AM

    Hi Lynn,
    Before implementation need to understand all areas to complete this task. Beacuse I am beginners in this technology. Sorry to trouble you. I ve to give concrete information to customer, that's y am clarifing all my doubts. Hope u understand
    I

    Then show us what you have done so far to accomplish the task at hand.

    Plus, we all have been beginners at one time.  You learn by doing.

  • Hi Lynn,

    thanks for your prompt response.

    I have  executed below command but am getting error , can you please help me what could the reason.

    Error :-
    bcp test in "/xxxxx/satya.dat" -c -t -S 10.xxxxx.32,xxx5 -d test-U sa

    LState = S1000, NativeError = 0
    Error = [Microsoft][ODBC Driver 13 for SQL Server]Unable to open BCP host data-file

    when am trying to run command from remote box to SQL server am getting following error.
    Error 2 :-

    SQLState = 08001, NativeError = 53
    Error = [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53].
    SQLState = 08001, NativeError = 53
    Error = [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection t
    if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
    SQLState = S1T00, NativeError = 0
    Error = [Microsoft][SQL Server Native Client 10.0]Login timeout expired

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic. Login to reply