options for a column

  • We have a view that is using concatenate string for street.( prefix+ streetname+ suffix) Now since we are using entity framework in front end, we would like to use it as a a table.

    We found there may be better add an extra column as a computed column in the table.

    Or another option, doing update or insert trigger, inserting or update the street by concatenating using other columns.

    which should be the better option?

    Thanks

  • There are couple of options:

    1. Do you use actual street name anywhere else. Or else you can insert the street name with prefix and suffix. This would be the most performant I think.

    2. If 1st option is not possible then I would go for calculated column. Not sure if Entity framework requires it to be persisted or not.

  • mayurkb (6/17/2013)


    There are couple of options:

    1. Do you use actual street name anywhere else. Or else you can insert the street name with prefix and suffix. This would be the most performant I think.

    2. If 1st option is not possible then I would go for calculated column. Not sure if Entity framework requires it to be persisted or not.

    I am not sure what you mean by first option.

    This is the an extra column we want to add to this table.

    It will use only in this table. And if we want use it we will join this table to get it.

  • With the first option I mean that the new column you are thinking of adding is (prefix+ streetname+ suffix), but if you are not going to be using "streetname" part of it anywhere else then you dont need this existing column so this column will be replaced with (prefix+ streetname+ suffix).

  • I do need the streetname there.

    Actually more columns are existing, I make it simpler and just said prefix+ streetname +suffix.

    Actually we have houseModifier + prefix+ streetname+ suffix as an extra column street.

    The other columns like housemodifier, prefix, streetname, suffix, we would like them to be there in table too.

  • Ok. Computed column sounds like the obvious choice then.

  • Thanks

  • Ignore my recent post, removed

  • 1. Are these all columnnames on the table?

    2. You dont need alias name here.

    Look at this sample I created:

    create table dbo.tbltemp

    (

    houseNumber int not null,

    Modifier nvarchar(20),

    comp as CAST(houseNumber AS VARCHAR(20))+ COALESCE(' ' + Modifier, '')

    )

  • THanks, that is what I found out.

    No alias name.

Viewing 10 posts - 1 through 9 (of 9 total)

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