Solved

How to use Exceptional Handling in this procedure

Posted on 2013-05-24
8
243 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
  • 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
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, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

810 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