How do I...get ISNULL Expression in Stored Procedure

Posted by Self-Innovator under Sql Server on 8/20/2014 | Points: 10 | Views : 403 | Status : [Member] | Replies : 1
Hi ,
I have an requirement for SP in Sql Server
If Agent.FirstName and Agent.LastName in Agent_Hierarchy is Null Then' I need to Pick
Agent.FirstName and Agent.LastName from hagent of Different Data base. The below is my Code but i am unable to get the result


Any one can find soln..

CREATE PROCEDURE [dbo].[WIN_IdleHoursAgent]          
(
@StartDate AS SMALLDATETIME

)
AS
DECLARE
@SQL VARCHAR(MAX)
@AgentName VARCHAR(MAX)
SET @AgentName=ISNULL(AH.Agent_LastName,[CS_RAW_DATA].[dbo].[hagent].[Item_Name]) AND ISNULL(AH.Agent_LastName,[CS_RAW_DATA].[dbo].[hagent].[Item_Name])
SELECT @AgentName=@AgentName
BEGIN
SET @SQL = '
SELECT @AgentName As Agent_Name,
x.LogId As Agent_Id)x LEFT JOIN [WEDW].[dbo].[Agent_Hierarchy] AS AH
END


Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

Posted by: Bandi on: 8/20/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
SELECT @AgentName = ISNULL(AH.Agent_LastName,h.[Item_Name]) + ' ' +ISNULL(AH.Agent_LastName,h.[Item_Name]) 
FROM Agent_Hierarchy AH
LEFT JOIN [CS_RAW_DATA].[dbo].[hagent] h ON YourCondition ( i.e. AH.Column = h.Column)


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response