Click here to Skip to main content
15,897,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Assume this is my agent code

'DGP 1 01052013'

DGP is string

the last 8 digit is the current date and the in between integer is unique code ,its should be increase for every agent entry


it should be like

DGP 2 01052013
DGP 3 01052013
...
DGP 10 01052013

...
DGP 100 01052013
no spaces between the code.

Solutions..?
Posted
Comments
VICK 29-Oct-13 1:27am    
What have you tried and Where You are stuck?? Post your query..
King Fisher 29-Oct-13 1:52am    
select right(advisor_code,8)from tbl_advisor_table

select (SUBSTRING (advisor_code,4,100)) from tbl_advisor_table

this is upto ma knowledge

 
Share this answer
 
Comments
King Fisher 29-Oct-13 2:00am    
i wanna increase the middle value
Thanks7872 29-Oct-13 2:08am    
Go through that Article,learn how to do that an implement it.
King Fisher 29-Oct-13 2:39am    
yes i do,
SQL
create table  ad
(
Id int identity(1,1),
Pid as case  len(Id) when 1 then 'DGP'+' '+convert(varchar,ID)+' '+'01052013'
when 2 then 'DGP'+convert(varchar,ID)+'01052013'
else 'DGP'+convert(varchar,ID)
end
)

INSERT INTO ad DEFAULT VALUES
 
Share this answer
 
Comments
King Fisher 29-Oct-13 2:30am    
it s nice .thank u
King Fisher 29-Oct-13 2:40am    
the last string should be the current date..
King Fisher 7-Dec-13 7:52am    
i hope u can ..
http://www.codeproject.com/Questions/693539/left-join-in-multiple-tables
 
Share this answer
 
Comments
King Fisher 7-Apr-15 2:38am    
I got solved this Question 1.5 yr ago. ;)
CHill60 7-Apr-15 3:27am    
Not only is this an old question (as the OP has pointed out to you) but your solution has nothing to do with the actual problem!

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