Reputation: 12037
Is there an more elegant solution to add certain headers to a SQL SELECT
statement?
For example, I have a dataset with the following:
A | B | C | D
=============
Y | 5 | 8 | Z
X | 4 | 8 | Z
etc...
In this case, the data isn't too important per se, however I would like to add related headers to the dataset, so the final output to look like:
Date Created: 1/1/11
Date Ran: 12/1/11
File Version: 123
A | B | C | D
=============
Y | 5 | 8 | Z
X | 4 | 8 | Z
All these will be internal tracking values already in the database, but I'd like to output them all as a single recordset to the final consumer.
I've done something a bit like it with some UNION ALL
's but it's far from great.
Upvotes: 0
Views: 1234
Reputation: 48422
A SQL Select statement returns rows and columns. It's not designed to format header and footer information, per se, the way you have described your requirement. And, IMO, this shouldn't be the function of a RDMS. Formatting like this should be done on a client or a service that makes a SQL call, not on a SQL Server itself.
Upvotes: 1