MSSQLTips.com - your daily source for SQL Server tips

Google
 
Web mssqltips.com

ESSENTIALS: Home | Tips | Search | Categories | Top 10 | Products | Authors | Blogs | Forums | Webcasts | Advertise | About
How to ImportFile using VBscript on a SSIS package - MSSQLTips

MSSQLTips

MSSQLTips.com - your daily source for SQL Server tips
Welcome to MSSQLTips Sign in | Join | Help
in Search

How to ImportFile using VBscript on a SSIS package

Last post 10-13-2008 8:16 AM by grobido. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 10-13-2008 3:49 AM

    • Tebogo
    • Top 200 Contributor
    • Joined on 10-13-2008
    • Posts 2

    How to ImportFile using VBscript on a SSIS package

     Hi All

    How do I convert the below code to work using VBscript in SQL 2005.Please help urgently if you can. This code was used in Access database and sometimes it was giving Errors.


    Function ImportFile()

    'change the name of the constant to the report/table imported
    Const conINPUTTABLE = "TSM83D"
    Const conIMPORTSPECNAME = "TSM83D Import Specification"
    Const conPATHTOFILE = "C:\TSM83D.txt"


    On Error GoTo errImport

        'delete old
        DoCmd.DeleteObject acTable, conINPUTTABLE
       
        'import new
        DoCmd.TransferText acImportFixed, conIMPORTSPECNAME, conINPUTTABLE, conPATHTOFILE, False, ""
        MsgBox "Finished importing file to " & conINPUTTABLE & ".", , "File Imported"

    Exit Function

    errImport:
    'if old table not found, table does not exist therefore ignore
    If Err.Number = 3011 Then
        Resume Next 'carry on with the next step
    Else
        MsgBox Err.Number & " " & Err.Description
        Exit Function
    End If
    End Function

    Filed under: ,
  • 10-13-2008 8:16 AM In reply to

    • grobido
    • Top 10 Contributor
    • Joined on 10-11-2007
    • Wilton, NH
    • Posts 73

    Re: How to ImportFile using VBscript on a SSIS package

    If you want to just import this data into SQL Server 2005 you could just use the "Data Flow Task" to do the import.  There is not a need to use VBScript.

    Also, here are some other options to import the data into SQL Server 2005:

    http://www.mssqltips.com/tip.asp?tip=1207

Page 1 of 1 (2 items)