title: How to convert datatable from UDF in SQL?
body: <p>This Codes give me error:<br><strong>Msg 156, Level 15, State 1, Procedure DefaultActivity, Line 2
  Incorrect syntax near the keyword 'RETURN'.
  Msg 137, Level 15, State 2, Procedure DefaultActivity, Line 3
  Must declare the scalar variable "@returnTable".
  Msg 1087, Level 15, State 2, Procedure DefaultActivity, Line 18
  Must declare the table variable "@returnTable".</strong></p>
  
  <pre><code>CREATE FUNCTION dbo.DefaultActivity
  RETURNS
      @returnTable table (
  [VisitingCount] int,
  [Time] nvarchar(50)
  )
  
  AS
  BEGIN
  
  DECLARE @DateNow DATETIME,@i int
  set @DateNow='00:00'
  set @i=1;
  
      while(@i&#60;1440)
          begin
              set @DateNow=DATEADD(minute, 1, @DateNow)
                  insert into @returnTable ([VisitingCount], [Time]) values(0, right(left(convert(nvarchar, @DateNow, 121), 16), 5))
              set @i=@i+1
          end
  
      RETURN
  END
  </code></pre>