Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Prefix to a Identity Column

Author  Topic 

ramkirangj
Starting Member

7 Posts

Posted - 2008-11-21 : 05:24:58
Hi every one
I have table "Qualification" with a column "Code" as identity.

The problem is in my table i want to have prefix as 'Q' to that identity column

How can i get this

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-21 : 05:37:01
In your query? SELECT Code AS qCode ...
Or in your table? sp_rename...



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-21 : 06:23:27
create a new column on the fly as

SELECT 'Q' + CAST(youridentitycolumn as varchar(10)) AS NewCol,...



alternatively if you want this to held in table create another computed column based on identity column as

CREATE TABLE
(
IDCol int identity(1,1),
....
NewCol AS 'Q' + CAST(IDCol AS varchar(10))
)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-21 : 07:33:40
or do it in fornt end application

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -