Flat file source import to SQL databse

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Devilxpto
    New Member
    • Mar 2007
    • 1

    Flat file source import to SQL databse

    I need help on how to import a Flat file source into SQL database, but the name of the file (part of the name) changes everyday. How can I create a method to import the file everyday into a new table without automatically ?
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    Try this:


    [PHP]DECLARE @FilePath varchar(50), @SQL varchar(8000)

    select @FilePath = '\\servernamehe re\ftproot$\TES T'

    SELECT @SQL = 'SELECT *
    FROM OpenDataSource( ''Microsoft.Jet .OLEDB.4.0'',
    ''Data Source="' + @FilePath + '";Extended properties=Text '')...TEST#txt'

    execute(@SQL)[/PHP]

    It works on one of my servers and not on another.
    TEST#txt is file name. You can change it.

    Comment

    Working...