title: Create Function error SQL SCRIPT
body: <p>Trying to create a function but i dont know whats wrong with it  . It gives the error Incorrect syntax near the keyword 'WITH'. </p>
  
  <pre><code> CREATE FUNCTION dbo.get_numseq (@max_rows AS BIGINT,@min_rows AS BIGINT) RETURNS TABLE
      AS 
      -- returns up to 4,294,967,296 records 
      WITH 
        lv0 AS (SELECT 0 AS g UNION ALL SELECT 0), 
        lv1 AS (SELECT 0 AS g FROM lv0 AS a CROSS JOIN lv0 AS b), 
        lv2 AS (SELECT 0 AS g FROM lv1 AS a CROSS JOIN lv1 AS b), 
        lv3 AS (SELECT 0 AS g FROM lv2 AS a CROSS JOIN lv2 AS b), 
        lv4 AS (SELECT 0 AS g FROM lv3 AS a CROSS JOIN lv3 AS b), 
        lv5 AS (SELECT 0 AS g FROM lv4 AS a CROSS JOIN lv4 AS b), 
  
        Nums AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS n FROM lv5) 
  
        SELECT n FROM Nums where n &gt;= @min_rows and n &lt;= @max_rows ORDER BY n
      GO 
  </code></pre>