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
 General SQL Server Forums
 New to SQL Server Programming
 Trimming Data

Author  Topic 

Les.61
Starting Member

49 Posts

Posted - 2009-11-16 : 23:12:30
I have a table with field like
S1
S1.1
S10
S10.2

I need to be able to trim so it only shows as
S1
S1
S10
S10

in a seperate column in a view.

The reults could be 2 or 3 characters and I have approx 50 different types that need to be trimmed.

Any suggesions?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-11-16 : 23:21:07
remove anything after the dot ?

select case when charindex('.', col) <> 0
then left(col, charindex('.', col) - 1)
else col
end



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

Go to Top of Page

Les.61
Starting Member

49 Posts

Posted - 2009-11-16 : 23:39:32
KH

Worked a treat. Yes it was to delete anything after the dot.

Many Thanks
Go to Top of Page
   

- Advertisement -