Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 No result from Stored Proc

Author  Topic 

kamnandi
Starting Member

6 Posts

Posted - 2010-11-18 : 16:08:18
I created a stored procedure that gets the maximum for hours for monday to Friday and one for Saturdays and Sundays.


SELECT SUM(Minutes) AS TotalMinutes 				FROM Clocking WHERE     (DATENAME(dw, ClockTime_In) IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday')) 				AND (StaffID = '10001') AND (ClockTime_In BETWEEN '2010.11.11' AND '2010.11.18')

This result gives me 345

If I put this exact same query in stored proc and assign a integer variable called @Week to it then I get Null

Select @Week = (SELECT SUM(Minutes) AS TotalMinutes 				FROM Clocking WHERE     (DATENAME(dw, ClockTime_In) IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday')) 				AND (StaffID = '10001') AND (ClockTime_In BETWEEN '2010.11.11' AND '2010.11.18')) 


What am I doing wrong.

Thx

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-11-18 : 17:29:34
Does it have anything to do with the date format? You could try using an ANSI standard date format instead of what you are using
Go to Top of Page

nishita_s
Yak Posting Veteran

61 Posts

Posted - 2010-11-19 : 01:43:11
Can you send table structure of table Clocking
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-19 : 03:16:29
Can you post the full procedure code?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -