Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Row Terminator not working:

Row Terminator not working:

Scheduled Pinned Locked Moved Database
sharepointdatabasecom
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shahzad Aslam
    wrote on last edited by
    #1

    Hi, I am using sql bulk copy to insert into table from txt file. The following code is is being used for row terminator but it does not work. it works with '\n'. But it should be work with Unix system as well. @BQUERY AS nVARCHAR(250) SET @BQUERY = 'BULK INSERT tblCustomer FROM ''' + @FILEPATH + ''' WITH ( FIRSTROW = 2, FIELDTERMINATOR = '','', ROWTERMINATOR = ''\x0A'' )' EXECUTE SP_EXECUTESQL @BQUERY

    Shahzad Aslam Software Engineer Email: shehzadaslam@hotmail.com

    A 1 Reply Last reply
    0
    • S Shahzad Aslam

      Hi, I am using sql bulk copy to insert into table from txt file. The following code is is being used for row terminator but it does not work. it works with '\n'. But it should be work with Unix system as well. @BQUERY AS nVARCHAR(250) SET @BQUERY = 'BULK INSERT tblCustomer FROM ''' + @FILEPATH + ''' WITH ( FIRSTROW = 2, FIELDTERMINATOR = '','', ROWTERMINATOR = ''\x0A'' )' EXECUTE SP_EXECUTESQL @BQUERY

      Shahzad Aslam Software Engineer Email: shehzadaslam@hotmail.com

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      Unix row terminators are not the same as windows. Windows uses \r\n, unix only uses \r Hope this helps

      Bob Ashfield Consultants Ltd

      S 1 Reply Last reply
      0
      • A Ashfield

        Unix row terminators are not the same as windows. Windows uses \r\n, unix only uses \r Hope this helps

        Bob Ashfield Consultants Ltd

        S Offline
        S Offline
        Shahzad Aslam
        wrote on last edited by
        #3

        I have tested this too, still not working.

        Shahzad Aslam Software Engineer Email: shehzadaslam@hotmail.com

        A 1 Reply Last reply
        0
        • S Shahzad Aslam

          I have tested this too, still not working.

          Shahzad Aslam Software Engineer Email: shehzadaslam@hotmail.com

          A Offline
          A Offline
          Ashfield
          wrote on last edited by
          #4

          Try doing a hex dump of your data and see exactly what character(s) delimit the lines. You can use multiple characters in your format file as record delimiters, so you should be OK.

          Bob Ashfield Consultants Ltd

          S 1 Reply Last reply
          0
          • A Ashfield

            Try doing a hex dump of your data and see exactly what character(s) delimit the lines. You can use multiple characters in your format file as record delimiters, so you should be OK.

            Bob Ashfield Consultants Ltd

            S Offline
            S Offline
            Shahzad Aslam
            wrote on last edited by
            #5

            I have read the file using StreamReader it has given some info about file. File is encoded with UTF-8 with code page 65001. It shows \n as line terminator which is not work with SQL bulk Insert.

            Shahzad Aslam Software Engineer Email: shehzadaslam@hotmail.com

            A 1 Reply Last reply
            0
            • S Shahzad Aslam

              I have read the file using StreamReader it has given some info about file. File is encoded with UTF-8 with code page 65001. It shows \n as line terminator which is not work with SQL bulk Insert.

              Shahzad Aslam Software Engineer Email: shehzadaslam@hotmail.com

              A Offline
              A Offline
              Ashfield
              wrote on last edited by
              #6

              I guess you tried ROWTERMINATOR = ''\x0D'' (hex for \n)

              Bob Ashfield Consultants Ltd

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups