Solved

How to use Exceptional Handling in this procedure

Posted on 2013-05-24
8
246 Views
Last Modified: 2013-05-31
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



ALTER PROCEDURE [dbo].[stp_Get_Conversation_History] --'C2OTAAC5'
      @ref_no VARCHAR(8)
AS
BEGIN
      
      SET NOCOUNT ON;

    select * from
      (
            SELECT  fbm_Id,fbm_Code,fbm_Salutation,fbm_User_Id,fbm_Name,fbm_EmailId,fbm_Mobile,fbm_IsClient,fbm_RefNo,fbm_MachineIP,
            CONVERT(varchar(6), DATEDIFF(day, fbm_Upd_Time,GETDATE())) + ' days '
            + CONVERT(varchar(6), (DATEDIFF(second, fbm_Upd_Time, GETDATE())/ 3600 % 24)) + ' hours '
            + Convert(varchar(5),RIGHT('0' + CONVERT(varchar(2), (DATEDIFF(second, fbm_Upd_Time, GETDATE()) % 3600) / 60),2))+ ' minutes ago' as fbm_Upd_Time,
            fbd_Id,fbd_Mast_Id,fbd_TypeId,fbd_AreaId,fbd_NatureId,fbd_Description,fbd_Subject_Line,fbd_StatusId,fbd_UserId,fbd_MailSent,fbd_DeptId,fbd_HandlingUserId,
            CONVERT(varchar(6), DATEDIFF(day, fbd_Upd_Time,GETDATE())) + ' days '
            + CONVERT(varchar(6), (DATEDIFF(second, fbd_Upd_Time, GETDATE())/ 3600 % 24)) + ' hours '
            + Convert(varchar(5),RIGHT('0' + CONVERT(varchar(2), (DATEDIFF(second, fbd_Upd_Time, GETDATE()) % 3600) / 60),2))+ ' minutes ago' as fbd_Upd_Time,
            fbt_Id,fbt_Type,
            convert(varchar(50),fbt_Upd_Time,100) as fbt_Upd_Time,fba_Id,fba_Area,
            convert(varchar(50),fba_Upd_Time,100) as fba_Upd_Time,fbs_Id,fbs_Status,
            convert(varchar(50),fbs_Upd_Time,100) as fbs_Upd_Time
            FROM tbl_FeedBack_Master A, tbl_FeedBack_Details B, tbl_FeedBack_Type C, tbl_Feedback_Area D,
            tbl_FeedBack_Status E
            WHERE  fbm_Id = fbd_Mast_Id
            AND fbd_TypeId = fbt_Id
            AND fbd_AreaId = fba_Id
            AND fbd_StatusId = fbs_Id
            And fbd_UserId = 0
            AND fbm_RefNo = @ref_no
            

            UNION ALL
            
            
            SELECT  fbm_Id,fbm_Code,fbm_Salutation,fbm_User_Id,Usm_User_Name as fbm_Name,'' fbm_EmailId,fbm_Mobile,fbm_IsClient,fbm_RefNo,fbm_MachineIP,
            CONVERT(varchar(6), DATEDIFF(day, fbm_Upd_Time,GETDATE())) + ' days '
            + CONVERT(varchar(6), (DATEDIFF(second, fbm_Upd_Time, GETDATE())/ 3600 % 24)) + ' hours '
            + Convert(varchar(5),RIGHT('0' + CONVERT(varchar(2), (DATEDIFF(second, fbm_Upd_Time, GETDATE()) % 3600) / 60),2))+ ' minutes ago' as fbm_Upd_Time,
            fbd_Id,fbd_Mast_Id,fbd_TypeId,fbd_AreaId,fbd_NatureId,fbd_Description,fbd_Subject_Line,fbd_StatusId,fbd_UserId,fbd_MailSent,fbd_DeptId,fbd_HandlingUserId,
            CONVERT(varchar(6), DATEDIFF(day, fbd_Upd_Time,GETDATE())) + ' days '
            + CONVERT(varchar(6), (DATEDIFF(second, fbd_Upd_Time, GETDATE())/ 3600 % 24)) + ' hours '
            + Convert(varchar(5),RIGHT('0' + CONVERT(varchar(2), (DATEDIFF(second, fbd_Upd_Time, GETDATE()) % 3600) / 60),2))+ ' minutes ago' as fbd_Upd_Time,
            fbt_Id,fbt_Type,
            convert(varchar(50),fbt_Upd_Time,100) as fbt_Upd_Time,fba_Id,fba_Area,
            convert(varchar(50),fba_Upd_Time,100) as fba_Upd_Time,fbs_Id,fbs_Status,
            convert(varchar(50),fbs_Upd_Time,100) as fbs_Upd_Time
            FROM tbl_FeedBack_Master A, tbl_FeedBack_Details B, tbl_FeedBack_Type C, tbl_Feedback_Area D,
            tbl_FeedBack_Status E,tbl_User_Master
            WHERE  fbm_Id = fbd_Mast_Id
            AND fbd_TypeId = fbt_Id
            AND fbd_AreaId = fba_Id
            AND fbd_StatusId = fbs_Id
            And fbd_UserId <>0
            and Usm_Id=fbd_UserId
            AND fbm_RefNo = @ref_no
      )X
      order by fbm_id, fbd_id

END
0
Comment
Question by:dynamicweb09
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 500 total points
ID: 39193807
Just checked the procedure script and it seems like you are performing a simple SELECT operation. SELECT operations as such doesn't require any Exception handling and hence you can ignore it.

Anyhow, since you have asked about Exceptional handling you can go through the BEGIN TRY .. CATCH statement syntaxes for your reference:

http://msdn.microsoft.com/en-us/library/ms179296%28v=sql.105%29.aspx
http://blog.sqlauthority.com/2007/04/11/sql-server-2005-explanation-of-trycatch-and-error-handling/
0
 
LVL 1

Author Comment

by:dynamicweb09
ID: 39193887
Thanks !
0
 
LVL 1

Author Comment

by:dynamicweb09
ID: 39193929
I've requested that this question be deleted for the following reason:

just like that
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 39193930
>> just like that

Kindly let me know why you are deleting the question with the above reason..
Also let me know whether you require more inputs on this question so that I can clarify accordingly.
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 39199080
Modulus_Twelve,

If dynamicweb09's doubt was clarified, I would request to close the question by accepting http:#a39193807 as the solution.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39199394
I agree.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question