I can use the PRINT statement in a stored procedure to debug my code. I see the output on the Messages tab in SQL Server Management Studio. How can I reset one or more integer SELECT outputs to the Messages tab?
My stored procedure returns multiple output variables, so returning a single dataset here is not an option. I am afraid to find a good way to debug my complex procedures.
, , , . . , NULL. , . :
Alter Procedure Foo(@Col1 int, @col2 varchar(20), @Debug Bit = NULL) As SET NOCOUNT ON If @Debug = 1 Begin Select * From SomeTable Where Col1 = @Col1 End -- The rest of your code here
, , 1 @Debug
" ", " " , PRINT SELECT.
, :
, . sp.
CREATE TABLE ##t1 (x int) GO CREATE PROCEDURE Foo AS BEGIN TRUNCATE TABLE ##t1 INSERT INTO ##t1 SELECT column FROM table; END GO exec Foo; select x from ##t1;
? , , . "", . :
select 'checkpoint1',a,b,c from table1 .... select 'table @a', * from @a .... <actual query here>
, .