| Author |
Topic |
|
caesarhernandez
Starting Member
4 Posts |
Posted - 2011-10-16 : 00:43:47
|
| Hello,I am trying to output a very large amount of text to the results window, but it seems it has a limited number of characters (if not and I'm missing something, that would be great).So my idea was to output the results to a file and just keep that file open in SSMS such that each time the sql is executed, the open file would just get updated each time. So I'm doing something like this to test:declare @sql varchar(max)set @sql = 'hello ' + CHAR(13) + 'world'declare @cmd varchar(1000)select @cmd = 'osql -U <user> -P <password> -S <the_server> -Q" print ''' + @sql + ''' " -o"c:\osqloutput.txt" -w500'exec master..xp_cmdshell @cmd...but the problem now is that the newline character is not doing anything and I can't figure out why. Any help would be greatly appreciated.Thank you,Caesar |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-16 : 00:56:02
|
try likedeclare @sql varchar(max)set @sql = 'hello ' + CHAR(10) + CHAR(13) + 'world'..... ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
caesarhernandez
Starting Member
4 Posts |
Posted - 2011-10-16 : 00:58:04
|
quote: Originally posted by visakh16 try likedeclare @sql varchar(max)set @sql = 'hello ' + CHAR(10) + CHAR(13) + 'world'.....
I got this as a result when doing that:Msg 105, Level 15, State 1, Server CAESARLAP\SQL2K8, Line 1Unclosed quotation mark after the character string 'hello '.Msg 102, Level 15, State 1, Server CAESARLAP\SQL2K8, Line 1Incorrect syntax near 'hello |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-16 : 01:03:22
|
| nope. thats not correct. the query is running fine for me. may be you've selected only part of statement and running------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
caesarhernandez
Starting Member
4 Posts |
Posted - 2011-10-16 : 01:06:00
|
| Really?...hmmm here is what I'm executing that is giving me the error:declare @sql varchar(max)set @sql = 'hello ' + CHAR(10) + CHAR(13) + 'world' declare @cmd varchar(1000)select @cmd = 'osql -U sa -P K67N5150 -S .\SQL2K8 -Q" print ''' + @sql + ''' " -o"c:\osqloutput.txt" -w500'exec master..xp_cmdshell @cmd |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-16 : 01:21:53
|
can you try like this?declare @sql varchar(max)set @sql = 'hello '' + CHAR(10) + CHAR(13) + '' world' declare @cmd varchar(1000)select @cmd = 'osql -U sa -P K67N5150 -S .\SQL2K8 -Q" print ''' + @sql + ''' " -o"c:\osqloutput.txt" -w500'exec master..xp_cmdshell @cmd ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
caesarhernandez
Starting Member
4 Posts |
Posted - 2011-10-16 : 01:25:08
|
| Ahh that is it...thank you! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-16 : 01:25:55
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|