Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Removing Data

Author  Topic 

KingCarlos
Yak Posting Veteran

74 Posts

Posted - 2014-07-15 : 02:20:19
I have some data in a field where the data can be

0001b
0001a
0001c
0001d

How do I remove the 0001?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-07-15 : 02:26:02
[code]replace(col, '0001', '')[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

KingCarlos
Yak Posting Veteran

74 Posts

Posted - 2014-07-15 : 02:36:45
thanks for the reply but what if 0001 could be 0002 or 1234 what I need to know is how to remove the first 4 digits to leave the letter value
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-07-15 : 02:45:26
always the first 4 digits ?

stuff(col, 1, 4, '')


or

right(col, len(col) - 4)



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -