title: create SQL-view with parameter
body: <pre><code>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
  </code></pre>
  
  <p>I have a sql query like this, and I need to create a view with this one.....is it possible..</p>
  
  <p>I created a function for this like</p>
  
  <pre><code>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
  
  )
  </code></pre>
  
  <p>the view is created successfully....but when I call the view like</p>
  
  <pre><code> select * from dbo.Attendance('2012-04-11')
  </code></pre>
  
  <p>it reports error like "Conversion failed when converting date and/or time from character string."......how can I call this function</p>