如何查找在上次运行时传递到存储过程的值

时间:2014-01-16 13:12:19

标签: sql stored-procedures sql-server-2012-express

我的Web应用程序正在调用存储过程,但未在ASP.net页面中返回所需的结果。当我通过提供相同的值在sql server中执行存储过程时,我得到了所需的结果。有什么方法可以告诉我们在网页调用时将哪些值传递到存储过程?

注意:我使用的是sql server 2012 express。

Create PROCEDURE [dbo].[spvolview] 
    @Gender nvarchar(50), 
    @Age int,
    @Country nvarchar(100)
AS 


select 
clinical_study.BRIEF_TITLE, clinical_study.OVERALL_STATUS, clinical_study.PHASE, clinical_study.STUDY_TYPE, clinical_study.GENDER, location_countries.COUNTRY, facilities.CITY
from clinical_study
inner join location_countries
ON clinical_study.NCT_ID=location_countries.NCT_ID
inner join facilities
on clinical_study.NCT_ID = facilities.NCT_ID
where (clinical_study.GENDER LIKE '%'+@Gender+'%' or clinical_study.GENDER like 'Both')
and clinical_study.HEALTHY_VOLUNTEERS <> 'No'
and clinical_study.OVERALL_STATUS like 'Rec%'
and @Age>(case when isnumeric(minimum_age)=1 then left(minimum_age,2) end) 
and @Age<(case when isnumeric(MAXIMUM_AGE)=1 then left(MAXIMUM_AGE,2) end)
and  location_countries.COUNTRY = @Country

1 个答案:

答案 0 :(得分:0)

如果您想“查看在数据库本身中为商店过程提供的值”,则可以创建一个简单的表并让您的商店过程在其中写入参数的值:

  1. 创建存储值的表格(例如,在“新查询”标签中使用以下代码):

    CREATE TABLE [dbo].[TMP_LOG](
        [id] [bigint] IDENTITY(1,1) NOT NULL,
        [Gender] [nvarchar](50) NULL,
        [Age] [int] NULL,
        [Country] [nvarchar](100) NULL)
    
  2. 编辑存储过程,在过程开始时(insert语句之前)添加select语句:

    insert into [dbo].[TMP_LOG] select  @Gender, @Age, @Country