Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2002
    Location
    India
    Posts
    38

    Unanswered: Need Select Query

    Hi to all
    I Need a sql Qery for Text files.
    Fist I want to know will it be possible to select the All Filelds fromText file....?

    I just thoght of like
    Select * from MyTextFile.Txt

    Please Help me.
    -- Prasad --

  2. #2
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    to my knowledge there isn't a way to do this via Transact SQL. If you have access to the xp_cmdshell stored procedure yo umight try something like:

    Code:
    --------------------------------------------------------------------------------------------------
    master.dbo.xp_cmdshell 'type MyTextFile.Txt'
    --------------------------------------------------------------------------------------------------

    Of course you will need to fully qualify the path to the text file as SQL server would assume (based on the above) that MyTextFile.Txt is on drive C: of your SQL server.
    Paul Young
    (Knowledge is power! Get some!)

  3. #3
    Join Date
    Feb 2002
    Location
    India
    Posts
    38
    I just tried like this
    master.dbo.xp_cmdshell 'type C:\Sample.Txt'

    I got the message as follows
    Code:
    outpur
    The system cannot find the file specified.
    NULL
    
    (2 row(s) affected)
    Last edited by buddu; 07-23-02 at 09:17.
    -- Prasad --

  4. #4
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    again, xp_cmdshell will look on your sql server for the file NOT your local PC. Try this and see what you get:

    code:
    --------------------------------------------------------------------------------------------------
    master.dbo.xp_cmdshell 'dir'
    master.dbo.xp_cmdshell 'type c:\boot.ini'
    --------------------------------------------------------------------------------------------------
    Paul Young
    (Knowledge is power! Get some!)

  5. #5
    Join Date
    Feb 2002
    Location
    India
    Posts
    38
    Thanks a lot
    It is workig fine..
    -- Prasad --

Posting Permissions

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