| Author |
Topic |
|
Maquis
Starting Member
25 Posts |
Posted - 2003-11-13 : 12:40:05
|
| How do you suppress the headings on the output of a select statement? In Oracle there is a "set heading off" switch...is there something similar in MS SQL?Thanks |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-11-13 : 12:43:43
|
| I do not know if there is a SET command for this; I couldn't find one in BOL. But you can turn off headers in Query Analyzer by going to Tools, Options, then to Results tab. Uncheck print column headers box.Tara |
 |
|
|
Maquis
Starting Member
25 Posts |
Posted - 2003-11-13 : 12:47:27
|
| Well, that works for QA, but what I'm actually trying to do is dynamically build a select query and send the output to a file, but I want no headings... |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-11-13 : 12:49:57
|
| Then use bcp or DTS for this. Both will allow the option to not have the headings in the file.Tara |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-11-13 : 12:59:10
|
BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...BCP...seemed to have gotten carried away...Also, if you put your reesult pain in grid mode and save it, you won't get any headers...in a csv file...But if what you're doing is so manual...why not cut out the heading (You know Oracle, don't you...)If one were to but read...it would be obvious....Brett8-) |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-11-13 : 13:19:25
|
Try this...USE NorthwindGODECLARE @Cmd varchar(8000), @Uid varchar(10), @Pid varchar(10), @tbName sysnameSELECT @tbname = 'Orders', @Uid = 'sa', @Pid = 'xxx'SELECT @cmd = 'bcp '+db_Name() + '..' + @tbName + ' out ' + db_Name() + '_' + @tbName + '.csv -c -S'+@@SERVERNAME+' -U'+@Uid+' -P'+@Pid SELECT @cmdEXEC master..xp_cmdshell @cmd Just need to change the password...Brett8-) |
 |
|
|
Maquis
Starting Member
25 Posts |
Posted - 2003-11-13 : 15:58:36
|
| OK, I haven't used bcp much, I want to throw the output of 2 different select statements into the same file (actually just throw a trailer record into the file). I tried to use bcp twice, and it appears to overwrite the first, instead of adding the 2nd select output to the end. And no, I can't use a union because the 2 selects have different numbers of expressions. Thanks again. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-11-13 : 16:27:49
|
| You could put the results into two files, then run this to concatenate them:type *.txt > C:\Temp\Concatfile.txtYou could use xp_cmdshell to do the above command so that you stay within SQL Server.Tara |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-11-13 : 17:54:32
|
Good one Tara! I didn't think of that one. Very clever ! (and a nice old-fashioned use of DOS features!) - Jeff |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-11-14 : 15:33:18
|
| That's why she's the princess!Command line junkies...uniteBrett8-) |
 |
|
|
Sitka
Aged Yak Warrior
571 Posts |
Posted - 2003-11-14 : 18:31:30
|
| I don't know how many of you got vs.net early downloads but it was three files (CD size) that had to be built into one exegreat fun using copy append feature to do it for a result of 1.5 GIG file. Now where did I put that hard drive space? |
 |
|
|
|