Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Add alphanumeric identity column

Posted on 2014-01-22
2
306 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 143

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

856 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