October 12, 2006 at 2:53 am
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
October 12, 2006 at 7:32 am
exec
dbo.xp_readerrorlog -1, 'File Name'
Mohan
October 13, 2006 at 9:14 am
Use BULK INSERT with a format file.
October 13, 2006 at 2:21 pm
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' .
October 13, 2006 at 3:16 pm
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