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??