declare @Date DateTime
set @Date='2012-04-16'
select s.sid,'Status'=case a.sid when isnull(a.sid,null)
then 'absent' else 'present' end from
student s left outer join (select * from absent where date=@Date) as a
on s.sid=a.sid
I have a sql query like this, and I need to create a view with this one.....is it possible..
I created a function for this like
CREATE FUNCTION dbo.Attendance (@Date DateTime)
RETURNS TABLE
AS
RETURN
(
select s.sid,'Status'=case a.sid when isnull(a.sid,null)
then 'absent' else 'present' end from
student s left outer join (select * from absent where date=@Date) as a
on s.sid=a.sid
)
the view is created successfully....but when I call the view like
select * from dbo.Attendance('2012-04-11')
it reports error like "Conversion failed when converting date and/or time from character string."......how can I call this function