Solved

Add alphanumeric identity column

Posted on 2014-01-22
2
304 Views
Last Modified: 2014-01-23
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
Comment
Question by:TimHudspith
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39802427
You want something like:
ALTER TABLE T_MyTable
   ADD [ID2]  AS ('A'+CONVERT([varchar],[ID],0))

Open in new window

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39802451
I confirm the above. it's not only a technical limitation, but also a matter of normalization of database tables
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question