Import


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Import

  1. #1
    ronald Guest

    Import


    How can I Import text file to SQLServer using query analyzer?
    I need to import a delimited text file by "|" to SQL Server without using
    the DTS Transformation.

  2. #2
    DaveSatz Guest

    Re: Import

    this should help get you an answer:
    http://www.mssqlserver.com/faq/general-flatfile.asp
    "ronald" <jrapascual@mailcity.com> wrote in message
    news:3a9f497e$1@news.devx.com...
    >
    > How can I Import text file to SQLServer using query analyzer?
    > I need to import a delimited text file by "|" to SQL Server without using
    > the DTS Transformation.




  3. #3
    Andrew Prosser Guest

    Re: Import


    "ronald" <jrapascual@mailcity.com> wrote:
    >
    >How can I Import text file to SQLServer using query analyzer?
    >I need to import a delimited text file by "|" to SQL Server without using
    >the DTS Transformation.


    Try using the 'BULK INSERT' command, something like;

    DECLARE @filename VARCHAR(100), @command VARCHAR(200), @status INT
    SELECT @filename = 'myfile.dat'
    EXEC @status = xp_fileexist @filename
    IF @status <> 0
    PRINT 'File not found'
    ELSE
    BEGIN
    SELECT @command = 'BULK INSERT dbo.[mytable] from "' + @filename +
    '" FIELDTERMINATOR = "|"'
    EXEC (@command)
    END

    You might have to play around with the strings but I think its on the right
    lines.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center