Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

sql add blank row to result

Guest
Mar 17, 2009 Mar 17, 2009
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
TOPICS
Database access
24.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Mar 18, 2009 Mar 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!
Translate
Valorous Hero ,
Mar 17, 2009 Mar 17, 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 ..
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 17, 2009 Mar 17, 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!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 17, 2009 Mar 17, 2009
You have to use SELECT with the string literal

SELECT Category
FROM Syndicated
UNION
SELECT '<HI>'
ORDER BY Category
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 18, 2009 Mar 18, 2009
LATEST
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!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources