Skip to content

SQL Server create function procedure

Tako Lee edited this page Feb 18, 2014 · 7 revisions
  • Parameters
    • Fit into one line if possible

      • At the same line as CREATE keyword

        CREATE FUNCTION dbo.Fn_gettoporders(@custid AS INT,@n AS INT, @test AS CHAR)  
        RETURNS TABLE  
        AS  
          RETURN  
            SELECT TOP(@n) *  
            FROM   sales.salesorderheader  
            WHERE  customerid = @custid  
            ORDER  BY totaldue DESC  
        
        GO        
      • In new line

        CREATE FUNCTION dbo.Fn_gettoporders(
          @custid AS INT,@n AS INT, @test AS CHAR)  
        RETURNS TABLE  
        AS  
          RETURN  
            SELECT TOP(@n) *  
            FROM   sales.salesorderheader  
            WHERE  customerid = @custid  
            ORDER  BY totaldue DESC  
        
        GO        
    • Stacked parameters

Clone this wiki locally