February 10, 2009 at 10:36 am
I want to have 1 line for each row for the output. But the output file from the code below has extra lines in each row. What I am missing here? Any advice?
declare @cmd varchar(1000)
select @cmd = 'osql -E -S -h-1 -w 1000 -s ; -Q"select * from pubs.dbo.sysusers" -o"c:\myoutputfile.txt"'
exec master..xp_cmdshell @cmd
Thank you!
November 7, 2011 at 12:13 pm
this is an old post, but my poor solution seems to be a follow up DOS script that you can execute via cmdshell.
type outputfilename.txt | findstr -i [highlight="#987654"]commonString[/highlight] >2.txt
Fortunately, in my situation, I do have a string that always occurs, in my case the server name %COMPUTERNAME% or @@SERVERNAME.
November 7, 2011 at 5:35 pm
Since the -s parameter defaults to a space, you need to (IIRC) explicity say -s"" (dash s followed by two double quotes with no spaces in between).
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy