Computed Column Using User Function

  • I am trying to key a Personnel Table on a person's initials.

    Obviously there may be more than one person with the same initials.

    So I am trying to use a User Defined Function to see how many of a certain set of initials are already there, and add 1.

    But I cannot get the Computed Column Specification to accept a user Defined Function.

    any thoughts?

    help will be appreciated

  • Just curious, but does the index on the initials need to be unique?  If so, how will the individuals in question know what their unique initials are when you finish modifying them?  If you need to index on the initials knowing they aren't going to be unique, don't make the index unique.

  • yes, must be unique, DW1, DW2, DW3 etc., because the Initials are used elsewhere to identify the Person on task assignments and the like

    I could use an integer Key and be done with it, but the idea of using Initials appeals because it is concise and useful elsewhere

  • It's probaly deciding the computed column is non-deterministic thus not much good for a key as it could change could every time you query the table.

    Try changing the column to be a normal column and set a default constraint to generate the key using the user defined function when the row is first inserted.

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

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