I have a process where I am trying to run "sp_helptext" in OSQL and piping
the output to a file so that I could basically generate the "Create
Procedure" statement for a particular Stored Proc. When I run this - I am
getting extra blank lines in the output file.
For example, I run the following OSQL command to generate the pubs.ByRoyalty
stored procedure:
osql -n -h-1 -w180 -SServerName-dpubs -Usa -Psapass -Q"exec sp_Helptext
byroyalty" >ByRoyalty.sql
The contents of ByRoyaly.sql is below...(Note all the annoying blank lines).
Is there any osql switch that could eliminate these blank lines? I've tried
adjusting the -w switch and it has no affect.
Thanks!
CREATE PROCEDURE byroyalty @.percentage int
AS
select au_id from titleauthor
where titleauthor.royaltyper = @.percentageIf you can work with other tools like the query analyzer instead you can get
the desired output using the following script:
USE pubs
CREATE TABLE #ByRoyalty (output varchar(8000))
INSERT #ByRoyalty
EXEC sp_helptext byroyalty
SELECT * FROM #ByRoyalty
The trick now is to find a way to send the output to a file
Hope it helps
"TJTODD" wrote:
> I have a process where I am trying to run "sp_helptext" in OSQL and piping
> the output to a file so that I could basically generate the "Create
> Procedure" statement for a particular Stored Proc. When I run this - I am
> getting extra blank lines in the output file.
> For example, I run the following OSQL command to generate the pubs.ByRoyal
ty
> stored procedure:
> osql -n -h-1 -w180 -SServerName-dpubs -Usa -Psapass -Q"exec sp_Helptext
> byroyalty" >ByRoyalty.sql
> The contents of ByRoyaly.sql is below...(Note all the annoying blank lines
).
> Is there any osql switch that could eliminate these blank lines? I've tri
ed
> adjusting the -w switch and it has no affect.
> Thanks!
>
> CREATE PROCEDURE byroyalty @.percentage int
>
> AS
>
> select au_id from titleauthor
>
> where titleauthor.royaltyper = @.percentage
>
>
Wednesday, March 7, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment