BCP command executing in Putty

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

    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 "/spimi/progetti/inbound/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

    Check the network configuration in the server running SQL Server, make sure that Named Pipes is enabled.

  • 1.)  You have to have network connectivity between the SQL Server and the Linux Server, or nothing you do will work.   No network connectivity and you are simply going to have to hand-walk that file somewhere that the SQL Server has network connectivity to.  If you can't even ping the SQL Server from the Linux server, then BCP isn't going to work under any circumstances.  You would then have to find a means to move that file to a location that CAN get to the SQL Server...   There is no other alternative beyond moving the file to the SQL Server itself.   If the Linux server is in your DMZ, and the SQL Server is NOT in the DMZ, then that's your problem.  You are NOT going to want to move the SQL Server into the DMZ, but you ARE going to have to find a tool that can cross the router into the DMZ, grab the file, and put it somewhere that DOES have network connectivity to the SQL Server.

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

  • I use Python with Linux for SQL Server. This is where I just install pymssql module with Python 2.7 and connect directly to the server.

    http://www.pymssql.org/en/stable/


    import pymssql

    server = "localhost:1433"
    user = "dbuser"
    password = "password"

    conn = pymssql.connect(server, user, password, "tempdb")
    cursor = conn.cursor()

    cursor.execute("INSERT INTO dbo.SomeTable SELECT BLAHBLAH FROM dbo.OtherTable")

    # Commit your data
    conn.commit()

    Pretty easy to connect to SQL Server to select or insert things. In your case, you will likely want to use Pandas to read a CSV file and then go row-by-row over that CSV file to do an INSERT into the database. Then commit your records accordingly or use a stored proc.

Viewing 3 posts - 16 through 17 (of 17 total)

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