Use a (PERSISTED
) computed column:
ALTER TABLE dbo.YourTable ADD PrefixedAutoNumber AS CONCAT('S',AutoNumber) PERSISTED;
Then you don't need to INSERT
it, or anything else, it'll have simply have the value of your AutoNumber
column prefixed with an 'S'
. Persisting the column means you can add it to indexes, which'll help for performance if you'll going to be using the column for WHERE
clauses or JOIN
s.
If it is, however, purely for display/presentation purposes, and will never be used in the WHERE
/ON
then you don't need to persist the column.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…