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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Adding rows

Author  Topic 

Knarf180
Starting Member

42 Posts

Posted - 2005-05-12 : 12:17:26
Is it possible to add some additional rows to the return of a select statement?

For example, lets say my query returned the following (fields seperated by commas)

3333, Testing, SQLTeam
3334, Testing2, Forums
3335, Testing3, Mind Numbing

The data above would have been pulled directly from the database. Now lets say that every time this query runs I want to add a row which states: "4444, Static Row, This is static data".

I figured I could either..
1. Create a temp table and Union it to the results
- Temp tables are slow, dont really want to use them
2. Add a "Union All" followed by the addition
Ex: SELECT fld1, fld2, fld3 FROM table1
UNION ALL
SELECT '4444', 'Static Row', 'This is static data'
UNION ALL
SELECT '4445', 'Static Row', 'This is another static line'

The problem is that I need to add about 30 additional rows, I'm trying to figure out what the cleanest method would be.

Thanks for the help,
- Frank

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2005-05-12 : 12:58:18
why would you need a static row? row order != set data. If an application needs there to be a static row every X rows of data, insert them on the client side.
Go to Top of Page

Knarf180
Starting Member

42 Posts

Posted - 2005-05-12 : 13:17:25
The first field is the sort order, the static row is a section title labeling the items below it.

I try to make everything that may need to change (depending on if my boss sees her shadow in the morning) server side. Using a server side method, I wont have to build a new release of the application if something simple like wording changes.

- Frank
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-05-12 : 13:18:45
I would like to know why as well..

But I would create a permanent table...and to allow for mulitple variations of static data, I would add a static code, and union all the data



Brett

8-)
Go to Top of Page
   

- Advertisement -