Solved

How to use Exceptional Handling in this procedure

Posted on 2013-05-24
8
245 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

751 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