Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
bjoerns
Posting Yak Master
154 Posts |
Posted - 2008-12-18 : 07:12:39
|
Hi there,I have a stored procedure which returnsSELECT @headerUNION ALLSELECT <some real stuff> which is finally bcped into a file. Is there any guarantee that @header will always be the first row in my output?Thanks,Bjoern |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2008-12-18 : 07:33:20
|
| No.If you need a guaranteed order, use an order by statement--Gail ShawSQL Server MVP |
 |
|
|
bjoerns
Posting Yak Master
154 Posts |
Posted - 2008-12-18 : 07:47:15
|
Thanks, think I found a solution then:SELECT DataFROM( SELECT 1 AS IsHeader, @header as Data UNION ALL SELECT 0, <some real stuff>) as HeaderFirstORDER BY IsHeader DESC |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-12-18 : 08:52:32
|
You can also use a temp table with an identity (1, 1) column.insert ##temp values (@header)insert ##tempselect <cool stuff here>from ...order by...And then BCP using query outBCP "SELECT col1 FROM ##Temp order by identitycol" qoeryout ... ... E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|