Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

SQL User Defined Function Needed?

I am looking for a SQL Server User Defined Function code snippet that will take two parameters and return the lesser of the two.

2 Answers

Relevance
  • CatNip
    Lv 6
    1 decade ago
    Favorite Answer

    SQL Server 2005 ver.

    create function dbo.myFun(@a int, @b int)

    returns int

    as

    begin

    declare @tmp int

    if @a > @b

    set @tmp = @b

    else

    set @tmp = @a

    return @tmp

    end

  • ?
    Lv 4
    5 years ago

    Yea I ran into this one some years in the past its a doozy yet i became into waiting to get it fixed. On that column which you have the apostrophe you could desire to apply the replace function on it like - replace(<Column call> , '', '''') - which will restoration your situation with the apostrophe. replace(<Column call>, '''', '"') - this might restoration your situation with the double rates. What in reality your doing is changing the present rates that are seen as single rates to double rates

Still have questions? Get your answers by asking now.