Home Forums SQL Server 7,2000 General UDF in computed column of Temp table fails RE: UDF in computed column of Temp table fails

  • it seems you cannot reference a udf in a computed col from any other database not just tempdb. You would have to create the function in tempdb.

    i.e - this does not work either:

    use pubs

    go

    create function udf_isblank(@n varchar(20) = null, @ret varchar(20))

    returns varchar(20)

    as

    begin

    declare @NULL int

    set @NULL =  case when isnull(@n,'') = '' then @ret

      else @n

      end

    return @NULL

    end

    select pubs.dbo.udf_isblank('',0)

    use northwind

    go

    --drop table test

    create table test(

    val int,

    result as pubs.dbo.udf_isblank(val,0)

    )

    insert test (val) values(5)

    insert test (val) values('')

    insert test (val) values(null)

    select * from test