Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    4

    Unanswered: Create table from text file, extract data, create new table from extracted data....

    Hello all,

    Please help....

    I have a text file which needs to be created into a table (let's call it DataFile table). For now I'm just doing the manual DTS to import the txt into SQL server to create the table, which works. But here's my problem....

    I need to extract data from DataFile table, here's my query:

    select * from dbo.DataFile
    where DF_SC_Case_Nbr not like '0000%';

    Then I need to create a new table for the extracted data, let's call it ExtractedDataFile. But I don't know how to create a new table and insert the data I selected above into the new one.

    Also, can the extraction and the creation of new table be done in just one stored procedure? or is there any other way of doing all this (including the importation of the text file)?

    Any help would be highly appreciated.

    Thanks in advance.

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    select *
    INTO ExtractedDataFile
    from dbo.DataFile
    where DF_SC_Case_Nbr not like '0000%'
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    May 2004
    Posts
    4
    Thanks so much Brett!

    I have more question though.......

    I will be needing to do the importation of text file & extraction of data at least once a month. Then after I import & extract data I will need to append the extracted data into the table ExtractedDataFile. But I will only need to append the data if there is no duplicate DF_SC_Case_Nbr.

    Can all this be done in just one stored procedure? How will I do this?

    Thanks again.

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    What's a duplicate?

    Do you have books online?

    Open it up, and leave it open...

    Look into bcp
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •