February 21, 2006 at 8:05 am
i'm trying to read information from a text file,
and i need to do this from qa.
is this possible?
note:
not trying to query data from a .txt file, but rather
read say whats in the file. much like you would see
if you opened the text file in notepad.
thoughts?
_________________________
February 21, 2006 at 9:02 am
If I'm understanding you correctly you can just use File->Open or just drag and drop the file onto an open QA instance. However, QA needs to be connected to a database for you to be able to work, even if you are just "using it like notepad"
February 21, 2006 at 9:03 am
master..xp_cmdshell "type C:\test.txt"
-Krishnan
February 21, 2006 at 9:04 am
(1) the qa must have access to the folder where the text file resides; (2) is this a data file with column delimiter or free format ?
February 21, 2006 at 9:09 am
thanks for all the feed back.
i'm doing this for a job-step that will read various .txt files, and ouput to a notification e-mail.
example:
declare @errorlog
set @errorlog = (master..xp_cmdshell "type C:\test.txt")
--then the usual xp_send... type of thing.
@message = @errorlog
but now i can put in a bunch of different error logs
from various sources so to give a single comprehensive
e-mail with all potential .txt log files that you may
want to check.
let me see if i can give this a go.
thanks again.
cheers
_________________________
February 21, 2006 at 9:23 am
cool...
the xp_cmdshell worked, but having a bit of trouble
getting it to work if SET as a variable.
example:
declare @output
set @output = (master..xp_cmdshell "type C:\test.txt")
this doesn't seem to work.
forgive me if this is a simple question, but
what am i doing wrong?
_________________________
February 21, 2006 at 10:56 am
I would use the approach as follows:
job step should be of the type of Operating System Command. As a command I would do:
cscript myscript.vbs
and put all file reading and processing in VBscript that sends SMTP email. I do have several jobs like that.
Regards,Yelena Varsha
February 21, 2006 at 11:01 am
set nocount on
declare @output varchar(8000)
create table #output (outputtext varchar(8000))
insert into #output
exec master..xp_cmdshell "type C:\test.txt"
select @output=outputtext from #output
drop table #output
print @output
-Krishnan
February 22, 2006 at 7:22 am
As Krishnan shows, the standard output from the command shell can be captured in a table. The solution is lacking, however, in that it will only return one row from the results. If your shell returns more than one "line", there will be more than 1 row in the #output table.
Best to declare the table with an identity column, so that you can get all the rows back in order.
Like so:
set nocount on
declare @output varchar(8000)
create table #output (id int identity, outputtext varchar(8000))
insert into #output(outputtext)
exec master..xp_cmdshell "type C:\boot.ini"
select @output = ''
select @output=@output + outputtext + char(13) from #output
order by id
drop table #output
print @output
February 22, 2006 at 3:19 pm
and if xp_cmdshell is restricted because of security constraints, you always have the sp_OAxxxxxx procedures to help you out......
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply