July 6, 2010 at 5:33 am
@@RowCount counts the number of rows affected by the last statemen, and a SET affects no rows.
As far as I can see, you're never using the @AcceptCoaching variable anywhere. If not, then you don't need a set at all.
SET NOCOUNT ON;
IF EXISTS (
SELECT 1
FROM ContactTracking CT
WHERE CT.Accept_Coaching=1
AND HcnID = '00000014002'
AND CT.Contact_Date between (
SELECT max(program_start_date)
FROM programyear
where getdate() between program_start_date and program_end_date
)
AND (
SELECT max(program_end_date)
FROM programyear
where getdate() between program_start_date and program_end_date
)
)
BEGIN
SELECT
Coach.LastName + ', ' + Coach.FirstName AS Coach_Name,
Coach.Phone as Coach_Phone
FROM
LFLCoach.dbo.Participant
INNER JOIN LFLCoach.dbo.CoachPartXref ON Participant.ParticipantID = CoachPartXref.ParticipantID
INNER JOIN LFLCoach.dbo.CoachAcctXref ON CoachPartXref.CoachAcctXrefID = CoachAcctXref.CoachAcctXrefID
INNER JOIN LFLCoach.dbo.Coach ON CoachAcctXref.CoachID = Coach.CoachID
INNER JOIN LFLCoach.dbo.Accounts on Participant.Accountid = Accounts.Accountid
WHERE
Accounts.Acctid = 'pfizersd' and
Participant.SSNum = '00000014002'
END
ELSE
BEGIN
SELECT
'' as Coach_Name,
'' as Coach_Phone
END
END
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 6, 2010 at 5:38 am
Thanks a lot..
Viewing 2 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply