Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2005-08-04 : 23:24:45
|
| Hello,I have a plain text file called Orders.txt with the following three lines:Line1Line2Line3I'm trying to read that text and put it in a table. I'm using the sp_oamethod call as stated below. The code runs and reports that it was successful, but when I query the table it is empty and even the 'print' command doesn't print anything. Seems simple enough, but I can't see what I might be missing. Any help is appreciated.Thanks in advance!--PhBdeclare @objFSys intdeclare @objFile intdeclare @blnEndOfFile intdeclare @strLine varchar(40)CREATE TABLE #mytesttable (sometext text)exec sp_OACreate 'Scripting.FileSystemObject', @objFSys outexec sp_OAMethod @objFSys, 'OpenTextFile', @objFile out, 'C:\orders.txt', 1exec sp_OAMethod @objFile, 'AtEndOfStream', @blnEndOfFile outwhile @blnEndOfFile=0 beginexec sp_OAMethod @objFile, 'ReadLine', @strLine outselect @strLineINSERT INTO #mytesttable (sometext) VALUES(@strLine)print @strLineexec sp_OAMethod @objFile, 'AtEndOfStream', @blnEndOfFile outendexec sp_OADestroy @objFileexec sp_OADestroy @objFSysselect * from #mytesttable--PhB |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2005-08-05 : 00:29:20
|
| Works for me OK....Try calling sp_OAGetErrorInfo after sp_OAMethod/Create to get back specifics about the problem(s). It could be a simple permissions issue. Are you running this interactively or part of a job?Tim |
 |
|
|
|
|
|
|
|