Home Forums SQL Server 7,2000 T-SQL create single quotes around @variable RE: create single quotes around @variable

  • For older versions of SQL SERVER : A simple (non table valued) function >

    if object_id('fcnTEST') is not null

    drop function fcnTest;

    GO

    CREATEFUNCTION dbo.fcnTEST(@param decimal(10,3))

    RETURNS decimal(10,3)

    AS

    begin

    return @param *2

    end

    GO

    ----------------------------

    selectdbo.fcnTEST(t.[n]) as calc

    from(

    selectn

    fromtally /* the numbers table */

    wheren >=1 and n <= 100 /* <-- replace with your max value */

    )as t

    No need for cursors, looping or dynamic SQL

    ----------------------------------------------------