October 10, 2006 at 9:51 am
Is there is a way in a sql script to "echo" out lines to an output file?
We are running several sql scripts using OSQL from a Wise installation script and need to "show" progress by echoing out steps into the log file.
I am using the -o parameter to echo results of the script but all I get is:
(52 rows affected)
(52 rows affected)
(4 rows affected)
(1 row affected)
like that in the log file.
I'd like something like this:
updating table xyz:
(52 rows affected)
updating table abc:
(52 rows affected)
updating table ghi:
(4 rows affected)
updating table opq:
(1 row affected)
This way, I will know where I am in the script when it "craps out"...
October 10, 2006 at 10:19 am
This works and is pretty nice. I though about using it but wasn't sure it would work right.
PRINT "Updating DB_Update_Num to 61"
October 11, 2006 at 10:51 am
The simplest way to accomplish this is by using the -o argument.
When using osql -ofilename creates a file that contains all the output.
October 11, 2006 at 1:42 pm
I know that, that's what we're using. I just wanted to insert extra things into the output file kind of like progress desscriptions.
October 11, 2006 at 1:58 pm
Yes, I sorry. I didn't read it very closely the first time.
You can add a comment in the output file by adding a select statement in the sql script. (e.g.)
select "Updateing table a"
go
October 11, 2006 at 3:32 pm
We have decided to use: PRINT 'Updating DB_Update_Num to 61'
instead of the select you are showing.
October 11, 2006 at 10:10 pm
Mr B... PRINT is exactly what you are looking for... if you don't want the rowcounts to show up in "standard" format, you can do a SET NOCOUNT ON and format @@ROWCOUNT for a nicer output. Add couple of dashed lines by doing a PRINT REPLICATE(-,78) and your -o logging will look great and be really easy to read.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 12, 2006 at 7:29 am
Thanks a lot, Jeff, that is just what I needed.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply