Click here to Skip to main content
15,899,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i have data in a roe like:

empid
------
P0001717
P0001745
P0001746
P0001747
P0001748


now i want remove first 4 number from the row,the result should be
empid
-------
VB
1717
1745
1746
1747
1748
Posted
Updated 27-Aug-13 20:00pm
v2

Nawab... in your case you have to use replace, please see the below example

select replace(empid,'P000','') as empid1 from tablename

If you want to use it with update

update tablename set empid=replace(empid,'P000','') .....

Note: Please ensure that this is not the primary key field of the table
 
Share this answer
 
v3
Comments
Nawab Ahmad 28-Aug-13 2:41am    
Hi, thanks fro reply..
But i want modify the data save in same row it self..
so i need query with update..
Srinivas Kalabarigi 28-Aug-13 2:51am    
I have updated the solution... plz check
Nawab Ahmad 28-Aug-13 3:01am    
Thanks working after small modification..

update checkinout set emp_id=replace(emp_id,'P000','')
Srinivas Kalabarigi 28-Aug-13 3:06am    
ok plz mark as soltuion and rate... thanks Srinivas
Simple...
SQL
Select RIGHT(ColumnName,len(ColumnName)-4) as ColumnName from TableName
 
Share this answer
 
v2
Try this

C#
Select RIGHT(empid,4) from TableName
 
Share this answer
 
v2
I would suggest you go for this link.
where once you created the sp it will be used for many way, you can use for splitting string format as well as column format data.

sql-server-user-defined-function-to-split-the-string Or Column-by-special-char/[^]


Hope this will help you.
 
Share this answer
 
Comments
kishore sharma 28-Aug-13 5:17am    
i would request to please put the reason for down voting.so can't be repeated.
kishore sharma 28-Aug-13 5:19am    
Oho sorry it wont work for this case.

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