2016-10-12 44 views
-1

我有一个存储过程,一旦我把我的参数放在SSRS报告中我想更新列中的数据reason_for_exceptioning,笔记和异常取决于我放入参数中。SQL Server/SSRS - 使用存储过程来更新数据

CREATE PROCEDURE [dbo].[ExceptionOutages] 

    @start_date datetime 
    ,@hostname2 nvarchar(max) 
    ,@error_flag bit 

AS 
BEGIN 

SET NOCOUNT ON; 

UPDATE PostExceptionMatchingTable  
SET [reason_for_exceptioning] = @reason_for_exceptioning 
,[notes] = @notes 
,[exceptioned] = @exceptioned 

SELECT [client] 
    ,[hostname] 
    ,[hostname2] 
    ,[hostname_2] 
    ,[os] 
    ,[measure] 
    ,[end_seconds] 
    ,[start_seconds] 
    ,[error_flag] 
    ,[end_datetime] 
    ,[start_datetime] 
    ,[end_date] 
    ,[start_date] 
    ,[datetime_difference] 
    ,[outage_seconds] 
    ,[percentage] 
    ,[inc_number] 
    ,[inc_brief_description] 
    ,[inc_status] 
    ,[inc_description] 
    ,[inc_priority] 
    ,[inc_sla_breach_exception] 
    ,[inc_sla_breach_reason] 
    ,[inc_status2] 
    ,[inc_report_date] 
    ,[inc_resolve_date_target] 
    ,[inc_affected_user_company] 
    ,[crq_number] 
    ,[crq_brief_description] 
    ,[crq_description] 
    ,[crq_change_timing] 
    ,[crq_start_date] 
    ,[crq_end_date] 
    ,[crq_outage_start_date] 
    ,[crq_outage_end_date] 
    ,[crq_priority] 
    ,[crq_request_status] 
    ,[Expr1] 
    ,[wlg_log_date] 
    ,[wlg_description] 
    ,[wlg_detailed_description] 
    ,[submit_date] 
    ,[hour_difference] 
    ,[day_difference] 
    ,[reason_for_exceptioning] 
    ,[notes] 
    ,[exceptioned] 
FROM [availability_outages].[dbo].[PostExceptionMatchingTable] 
where [start_date] = @start_date 
and [hostname2] = @hostname2 
and [error_flag] = @error_flag 

END 

我不完全知道从哪里把更新的存储过程

+0

只需在select语句之前编写更新语句即可。 – qxg

+0

我已经更新了上面的代码,但是我得到了标量变量错误 –

+0

where reason_for_exceptioning,notes,and exception from from? – qxg

回答

1

你可以把UPDATE select语句之前。只要在BEGIN..END块内,UPDATE应该可以在存储过程的任何部分中工作。