Are there any commands in the "51cto/bbs" SQL statement to clear the console display (return) data??

Source: Internet
Author: User

Original address: http://bbs.51cto.com/viewthread.php?tid=1133377&extra=&page=1

Problem Description:

As learning progresses, SQL statements become more complex.

In a SQL stored procedure, it is likely that multiple stored procedures are called. Resulting in a messy data return.
Ask how to clear out the data that is not needed to return the display.

In particular, when invoking SQL in other programming languages, the correct return data set cannot be obtained. .....

For example:
"Stored procedure A" has multiple SELECT statements,
SELECT @A;
EXEC @a=dbo.          [Stored procedure B] @B OUTPUT; --This [stored procedure B] Also contains the SELECT statement
SELECT @b,@a;

I want to only return the display "select @b,@a; "The result, how should it be written?"

Solution:

How do I get rid of output?

Use Insert exec to Splice

CREATE TABLE #Temp (outputdata varchar (MAX)) Goinsert into #Temp (outputdata) EXEC master.sys.x P_cmdshell '? '

Note: INSERT EXEC statements cannot be nested, please use carefully.

How do I control the output of the select result set?

Add a parameter to determine whether the return result

CREATE PROCEDURE nsp_test @IsReturn BIT = 1-whether the return result as BEGIN if @IsReturn = 1 B Egin SELECT * from TableName end end goexec nsp_test @IsReturn = 0



This article is from the SQL Server deep dives blog, so be sure to keep this source http://ultrasql.blog.51cto.com/9591438/1586056

Are there any commands in the "51cto/bbs" SQL statement to clear the console display (return) data??

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.