How to increment string value of six digit?

Posted by Shreedar under C# on 8/30/2015 | Points: 10 | Views : 359 | Status : [Member] | Replies : 2
I have a requirement like below.

In table I need to store id from the last insert id.
Suppose the last id column,
id is MD0004 , the next id should be MD0005.
I have a text box to take input like below

Quantity TextBox

Based on quantity given in TextBox,
I have to insert that many records.

How to find the last id and how to increment that MD0004 to MD0005, MD0006,MD0007 so on..

Regards

Sridhar Thota.
www.dotnet-sridhar.blogspot.com



Responses

Posted by: Jayakumars on: 8/31/2015 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Create Table tt
(
Eid int primary key identity(1,1)
ename varchar(50)
)

insert into tt VALUES('MD0004')
insert into tt VALUES('MD0005')
insert into tt VALUES('MD0006')

select top 1 * from tt order by ename desc

Mark as Answer if its helpful to you

Shreedar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shreedar on: 8/31/2015 [Member] Starter | Points: 25

Up
0
Down
Hello Jayakumar.

I think you didn't understand my question.
If we give 10 in textbox, then 10 records should be inserted in to sql table from code behind.
Id column should get incremented like if the last id is MD0001 next 10 records should be MD0002, MD0003 so on till MD0010

Regards

Sridhar Thota.
www.dotnet-sridhar.blogspot.com

Shreedar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response