Read psysical file from T-SQL

  • Hi!

    I use MSSQL 2k, and I want to read a file (etc: c:\test.dat) and place to a column. I can do it with Delphi, or VB, but I need to do this with transact SQL WITHOUT outer programs (like textcopy, bcp, etc).

    Thanx:

    Peter

  •   exec

    dbo.xp_readerrorlog -1, 'File Name'

    Mohan

  • Use BULK INSERT with a format file.

  • You can also use exec master.dbo.xp_cmdshell 'type c:\filename.txt' .

    If you want to save the data for further processing, you can create table #temp(my_data varchar(max)) and run insert into #temp exec master.dbo.xp_cmdshell 'type c:\filename.txt' .

     

  • And, showing there is more than one way to skn a cat, you can also use OPENROWSET or OPENDATASOURCE.

    Look in BOL at Importing and Exporting Bulk Data

    Hope this helps



    Mark

Viewing 5 posts - 1 through 4 (of 4 total)

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