Skip to main content
March 18, 2009
Answered

sql add blank row to result

  • March 18, 2009
  • 2 replies
  • 24637 views
Hi,

I currently use a temporary table to add a blank row to the top/beginning of my query results. I'm moving to MS SQL stored procedures and wanted to know if it's possible to add a blank row right into my SQL so I can eliminate the temporary table solution.

Any thoughts on this are appreciated!

cfwild
This topic has been closed for replies.
Correct answer
Hi,

Thanks for the insight. It worked perfectly! For anyone looking for just a blank row insert "above" the query results, here was the final code:

SELECT Category
FROM Syndicated
UNION
SELECT ''
ORDER BY Category

Again, thanks for the help!

2 replies

Inspiring
March 18, 2009
You have to use SELECT with the string literal

SELECT Category
FROM Syndicated
UNION
SELECT '<HI>'
ORDER BY Category
Correct answer
March 18, 2009
Hi,

Thanks for the insight. It worked perfectly! For anyone looking for just a blank row insert "above" the query results, here was the final code:

SELECT Category
FROM Syndicated
UNION
SELECT ''
ORDER BY Category

Again, thanks for the help!
Inspiring
March 18, 2009
> wanted to know if it's possible to add a blank row right into my SQL so I can eliminate
> the temporary table solution

You could use a union to merge your blank row with your other results and order it so the blank sorts on top. But why do you need a blank row? It sounds like mixing user interface code with database code ..
March 18, 2009
Hi,

Thanks for responding.

I fashioned this up, but I'm throwing an error:

SELECT S.Category
FROM Syndicated S
UNION '<HI>'
ORDER BY S.Category

Thoughts on getting this to work in tsql?

cfwild

My problem is that I'm binding this to the cfselect, the bind doesn't allow the queryposition above|below functionality to work. So I'm forced to a). temp table (which is working fine) or b). investigate adding into the sql. Thanks!