How to QUERY from the BCP output ?

  • Hi Every body.

    Suppose we have run the BCP command on a table and now we have a text file.

    Is it possible to use this text file with a Query and Cursors to navigate throught it ? ( HOW ? )

    Thanks alot for your help.

    __..._-__

  • The only way that I am aware of is if you would read that file back into a table and query that table, but that just puts you back at square one again doesn't it.  Why can't you query the data in your table instead of the file?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Thanks alot for your attention.

    Beacuse I make the text file on clients and then it is uploaded to a SQL Server located on Internet. ( Sql Server Host).

    That is why I need to Query that text file and use Cursors for it.

    __..._-__

  • I guess I'm still not quite clear on the need to query the text file (especially using cursors).  So you generate a text file on client machines using BCP, then you send them to a central repository on your Internet facing SQL Server?  Why not load the data into a table on your 'host' server and query it there?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Load your text file into Excel, or BCP in into an another table



    Bye
    Gabor

  • Thanks for your attention.

    I am thinking of this way :

    I make an XML file from my table ( Using BCP, QUERY & FOR XML option) then I can Upload it to my server. Afterwards I make an empty table with the same structure on the server and Import the XML file to it and then it is ok to use cursors on that table.

    But I am NOT sure wether or not, I can Import an XML file into a Table .... Maybe I should use the OPENXML or other commands ...

    I appreciate your opinions ...

    Thanks.

    __..._-__

  • You should not use XML for this.

    A simple BCP out to a TAB (or what ever) delimited file, then BCP in is the best and most efficient way. Instead of BCP you can use DTS as well.

    And instead of the BCP in you can use the TSQL bulk insert command



    Bye
    Gabor

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply