Importing a notepad txt file into SQL 2000 Server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kbaisch
    New Member
    • Mar 2007
    • 19

    Importing a notepad txt file into SQL 2000 Server

    I have been trying to import a notepad txt file into my SQL server. I go through the routine of importing it, either through table or DTS and it just hangs up, nothing happens. Do I need to parse the text file first? If I need to parse it, how do I do that? Does anyone have any idea on why it won't import? Thanks for helping.
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    Today is the same question from all people.

    Unfortunately I have the same answer. You can load data into a temp table with all character columns first and do parsing on database side while inserting data into a production table.

    Comment

    • kbaisch
      New Member
      • Mar 2007
      • 19

      #3
      Originally posted by iburyak
      Today is the same question from all people.

      Unfortunately I have the same answer. You can load data into a temp table with all character columns first and do parsing on database side while inserting data into a production table.
      By "temp table" do you mean a table in SQL? It won't load in SQL, that's my problem. It just hangs up and does nothing, status staying at 0. Any suggestions? Thanks for your help.

      Comment

      • iburyak
        Recognized Expert Top Contributor
        • Nov 2006
        • 1016

        #4
        You can use following ways to insert data into a table from a text file:
        1.
        [PHP]CREATE TABLE SomeTable (Results varchar(4000) null)
        go
        INSERT INTO SomeTable(Resul ts)
        exec ('master..xp_cm dshell ''type d:\yourfile.txt ''')[/PHP]
        2.
        [PHP]CREATE TABLE SomeTable (Results varchar(4000) null)
        go
        BULK INSERT YourDatabase.db o.[SomeTable]
        FROM 'd:\yourfile.tx t' [/PHP]
        3.
        [PHP]CREATE TABLE SomeTable (Results varchar(4000) null)
        go
        Insert into YourDatabase.db o.[SomeTable]
        SELECT *
        FROM OpenDataSource( 'Microsoft.Jet. OLEDB.4.0',
        'Data Source="d:\your file.txt";Exten ded properties=Text ')[/PHP]

        Comment

        • sweetmaster
          New Member
          • May 2007
          • 4

          #5
          Originally posted by iburyak
          You can use following ways to insert data into a table from a text file:
          1.
          [PHP]CREATE TABLE SomeTable (Results varchar(4000) null)
          go
          INSERT INTO SomeTable(Resul ts)
          exec ('master..xp_cm dshell ''type d:\yourfile.txt ''')[/PHP]
          2.
          [PHP]CREATE TABLE SomeTable (Results varchar(4000) null)
          go
          BULK INSERT YourDatabase.db o.[SomeTable]
          FROM 'd:\yourfile.tx t' [/PHP]
          3.
          [PHP]CREATE TABLE SomeTable (Results varchar(4000) null)
          go
          Insert into YourDatabase.db o.[SomeTable]
          SELECT *
          FROM OpenDataSource( 'Microsoft.Jet. OLEDB.4.0',
          'Data Source="d:\your file.txt";Exten ded properties=Text ')[/PHP]

          respected sir.
          i am also working on the same issue . i have a connection with sql server 2000 via odbc and i have got query results from sql server 2000 in php web page.
          would u please tell me that what is proper method of writing these commands in php.
          i write them as it as get nothing then i write with echo method and i get these lines at output as it is.
          kindly tell me how it would be beneficial.
          a bundle of thanks in advance
          regards
          maanijanjua

          Comment

          Working...