putting descriptions between different SELECTS in a Stored Proc

Posted on 2011-10-30
Last Modified: 2012-05-12
for simplicity sake, let's say there are 5 different SELECTS in a stored proc.. all the job for the stored proc is to return the 5 result sets to the user.

is there a way to put a description of the result set before each one is displayed?

Question by:25112
    LVL 21

    Expert Comment

    You can use comment
    LVL 5

    Author Comment

    i mean the output that the user will be seeing on the resultset.. ( are you saying comment inside your code)
    LVL 21

    Accepted Solution

    LVL 5

    Author Comment

    in my case, there will be lot more columns.. in this example, it worked good as there was only one column to output.. i want to give a title for each result set.
    LVL 75

    Assisted Solution

    by:Anthony Perkins
    I have no idea why you would want to do this, but if you insist you coud do something like this:

    SELECT 'Description for query1'
    SELECT query1 ...

    SELECT 'Description for query2'
    SELECT query2 ...

    SELECT 'Description for query3'
    SELECT query3 ...

    SELECT 'Description for query4'
    SELECT query4 ...

    SELECT 'Description for query5'
    SELECT query5 ...

    LVL 18

    Assisted Solution

    Add a column Description to each recordset
    SELECT 'Your description here' as Description , column1, ...columnN FROM ....

    LVL 5

    Author Comment

    it is a requirement given.. your ideas will fit the bill.

    thanks much.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    The steps for moving the system databases to a new location are documented in the following technical article: However sometimes after the moving process is finished, though SQL i…
    Introduced in Microsoft SQL Server 2005, the Copy Database Wizard ( is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
    Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
    Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now