• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 354
  • Last Modified:

Add alphanumeric identity column

I want to add a column to my table that takes the value of the identity column and prefixes it with 'A'. I don't know the syntax for specifying the varchar datatype within this statement:

ALTER TABLE T_MyTable 
ADD ID2 AS 'A' + ID

Open in new window

0
TimHudspith
Asked:
TimHudspith
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
You want something like:
ALTER TABLE T_MyTable
   ADD [ID2]  AS ('A'+CONVERT([varchar],[ID],0))

Open in new window

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I confirm the above. it's not only a technical limitation, but also a matter of normalization of database tables
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now