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 |
|
tuka
Starting Member
26 Posts |
Posted - 2006-12-23 : 11:29:20
|
| Hi,I am trying to add a single row at the top of a rescorset like select id, name from tb_industry how do I add at the top of that recordset a row 0, "-Select One-" so that the result looks like this ?id name0 -Select One-1 Agriculture2 AutomobileI have considered UNION but it requires a table to select from in the first plce acoording to few exmples I have seen. What I want to add is just a sible row to add options to a list box on an app. I would like the option to be included at the sql server layer. TIA, Tuka PS: Of course I can always generate a temporary table and do a UNION both that is a verbose way of doing it. I would like something a little more eleganet |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-12-23 : 11:37:12
|
| A union is the right way to goSELECT 0 AS ID, '-Select One-' AS NameUNIONSELECT ID, Name FROM tb_industryORDER BY ID |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2006-12-23 : 15:00:39
|
I would use UNION ALL in this case instead of UNION,UNION is more expensive than UNION ALL because it needs to check for dupes. www.elsasoft.org |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-24 : 23:34:53
|
| <<UNION is more expensive than UNION ALL because it needs to check for dupes.>>Also it will sort the recordsMadhivananFailing to plan is Planning to fail |
 |
|
|
tuka
Starting Member
26 Posts |
Posted - 2006-12-25 : 09:20:08
|
| Thanks a lot guys for the input. It was all very helpful.Cheers,Tuka |
 |
|
|
|
|
|