July 20, 2010 at 8:09 am
Hi!
I have big problem. I want to write into txt file data from table. With this "method"
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC @rc = sp_OAMethod @FileNameID, 'Write', Null , @VsebZapis
IF @rc <> 0 BEGIN PRINT 'Error: Writing string data to file' ENDs
and so on... and it works for one record in Table.
But if I have more records txt file is not strucured like table.
I want to have each record in table in one line in txt file.
thanks
July 20, 2010 at 8:22 am
I'm assuming the variable @VsebZapis is the string you are writing?
are you adding a CrLf to the end of it, so each record is on a single line in the file?
SET @VsebZapis = @VsebZapis + CHAR(13) + CHAR(10)
alternatively, you can use the WriteLine command, instead of Write:
EXEC @rc = sp_OAMethod @FileNameID, 'WriteLine', Null , @VsebZapis
WHILE @@FETCH_STATUS = 0
BEGIN
SET @VsebZapis = @VsebZapis + CHAR(13) + CHAR(10)
EXEC @rc = sp_OAMethod @FileNameID, 'Write', Null , @VsebZapis
IF @rc <> 0 BEGIN PRINT 'Error: Writing string data to file' ENDs
thanks[/quote]
Lowell
July 21, 2010 at 2:31 am
It works thanks 😉
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply