I am working on a C# application where i have to store values of article in sql server as i have 3 products (stone, diamonds, jewellery). Now during the initial process when i enter the product details let say i have to store value for a diamonds i put in the required details, now i want that in the database a sno value should be stored as a increment counter(D001) next time when i enter details for diamond the sno should be automatically stored as 002. Same is the case with stone , jewellery.

Diamonds: D001, D003, D003.....
Jewellery : J001, J002, J003.....
Stone: S001, S002, S003.....these all should be stored as sno in same database table. is it possible. Please help me through. waiting for are reply.Thanks in anticipation

You can either do this in C# or sql server, depends on you, I would suggest you to use sql server,
you can write a stored procedure, check if the string starts with either 'D', 'S' or 'J'.
depending on that, select top(1) from [Table] where product = [your condition] order by [product] desc. this will give u the last value inserted, use the substring to remove the first letter, and add a mathematical 1 to the remaining string, and combine them both.
and then insert the rest of the values.
This is how I followed.