Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have a SQl table of the form:-

Bill_ID:- pk int,
Billno:-varchar(50),
Item:-varchar,
Rate:-decimal,
Qty:- int.


I want the bill no to start with prefix A000. Like A0001,A0002.

Please help..
Thanks
Posted

1 solution

Hi

Try this....
SQL
SELECT 'A'+RIGHT('0000'+CAST(Bill_ID AS VARCHAR(10)),4)
FROM Table_Name 

But Don't change your PK data type....Keep it as INT and do what ever u need as per your requirements.

Regards,
GVPrabu
 
Share this answer
 
Comments
rupai99 27-Jul-13 14:56pm    
Please explain in detail. When to set column prefix?during table creation or during data insertion? and how...

thanks
gvprabu 31-Jul-13 8:21am    
hi....
U need to display like this right...
Don't change any thing in table creation or Insert time.While fetch the data from Database.. u need to use like this Query.

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