Learning Store procedure and debug in SQL Server 2008

来源:互联网 发布:计算机网络视频知乎 编辑:程序博客网 时间:2024/05/16 18:03

First store procedure:

 

 

USE [TourReseller]

GO

/****** Object:  StoredProcedure [dbo].[usp_users_login]    Script Date: 03/23/2011 17:01:12 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

 

ALTER procedure [dbo].[usp_users_login] (

                              @username varchar(250),

                              @password varchar(250),

                              @emailid varchar(250),

                              @ret int output

                             )

AS

  Begin

       set @ret=0;

       select @ret=1 

       from users 

       where (userName=isnull(@username,null) or [email]=isnull(@emailid,null) 

             and [password]=@password);

  End

 

 

Cool! So now we need to call the procedure and get return value....
DECLARE @ret int
EXEC dbo.usp_users_login 'Admin','admin','',@ret OUTPUT
SELECT @ret
How to debug?
You can not just step into a created procedure, you need to debug during calling the procedure.
You could put break point in the short paragragh above that calls the store procedure usp_users_login, and at the second sentence F11 to step in to the store procedure, to do the debug step by step! Really useful trick~

 

原创粉丝点击