March 27, 2010 at 2:14 am
Hi,
I want to increment one column like
BC1, BC2, Bc3, like this......
Is it possible by IDentity or any other way?
March 27, 2010 at 2:43 am
You cannot use an IDENTITY column for this. You will have to use a Computed Column.
DECLARE @tblTable TABLE
(
Col1 TINYINT IDENTITY(1,1) NOT NULL,
Col2 AS 'BC' + CAST( Col1 AS VARCHAR(3) ),
Col3 INT
)
INSERT INTO @tblTable VALUES( 1 )
INSERT INTO @tblTable VALUES( 2 )
INSERT INTO @tblTable VALUES( 3 )
INSERT INTO @tblTable VALUES( 4 )
INSERT INTO @tblTable VALUES( 5 )
SELECT * FROM @tblTable
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
March 27, 2010 at 12:16 pm
Wonderful solution Kingston !!!
March 27, 2010 at 1:07 pm
I agree that the solution is fine... but why the need? What is the business requirement for this? I ask for the same reason for the question in the original post... I just want to know. Thanks.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply