Is it Possible to use UDF as default values on a table column?

  • if

    exists (select * from dbo.sysobjects where id = object_id(N'[dbo].CC') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

    drop

    table [dbo].CC

    GO

    CREATE

    TABLE [dbo].[CC] (

    [Field1] [varchar]

    (7) NOT NULL ,

    [field2] [int]

    NOT NULL ,

    [field3] [tinyint]

    NULL ,

    [field4]

    bit DEFAULT dbo.fn_DetermineNonReplenish([field1], [field3], [field2])

    )

    GO

    Below is a error message:

    Msg 128, Level 15, State 1, Line 6

    "The name 'CIN' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted."

    Is there any other way I can use to achieve the same purpose of the above UDF function(fn_DetermineNonReplenish)?

  • I don't think that this is possible, although depending on the complexity of the UDF, you might be able to use a computed column.



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply