Click here to Skip to main content
15,921,174 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
You have to make a compliant register table from sql server
Compliants(CompliantID,Comp.Date,IpAdress,ProblemDesc,RespONSIBLE)

Compliant ID to be generated automatically as.If Resp. is Management Start with
M001(CompliantID)

like that..
If Network Person is responsible start with
N001(CompliantID)

if Others are responsible start with
O001(CompliantID)

like that.

With the help of stored procedure
It is done when i am insert a record,
if i give RespONSIBLE field as management it should generate the
CompliantID(AUTO GENERATE) as M001
OR
if i give RespONSIBLE field as Network Person it should generate the
CompliantID(AUTO GENERATE) as N001

if i give RespONSIBLE field as OTHERS it should generate the
CompliantID(AUTO GENERATE) as 0001


AND WHEN IAM TRY TO INSERT NEW RECORD IT SHOULD INCREMENT AS M002 OR N002 0R 0002
Posted
Updated 10-Jan-12 18:21pm
v3

1 solution

In general you should never concatenate different data to a single field.

In your case, I'd suggest that you keep the M/N/O in a separate field and the generated number in another. When the data is fetched you can concatenate these fields in the select.

Another thing is that never rely on this numberig having all values. Consider for example what happens when a row is deleted from the middle. So if this is an ordinal number for the data, you should create it again when fetching data in SELECT statement.
 
Share this answer
 
Comments
Amir Mahfoozi 11-Jan-12 0:45am    
+5 good points.
Wendelius 11-Jan-12 0:51am    
Thank you Amir :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900