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.
Author |
Topic |
ramsis
Starting Member
2 Posts |
Posted - 2010-09-16 : 08:58:19
|
Hope you can help me on this:SQL server 2003i have a column where i'd like to remove/delete the first word before "space" in each field of a column.how can i do this?for example: (skimmed milk 1L) to be (milk 1L)thanx,ramsis |
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-09-16 : 09:02:30
|
Try thisSelect right('skimmed milk 1L',len('skimmed milk 1L')-charindex(' ','skimmed milk 1L'))Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-16 : 12:28:07
|
quote: Originally posted by ramsis Hope you can help me on this:SQL server 2003i have a column where i'd like to remove/delete the first word before "space" in each field of a column.how can i do this?for example: (skimmed milk 1L) to be (milk 1L)thanx,ramsis
there's no 2003 version for SQL Server. May be you meant 2005anyways you can try the below:-select stuff('skimmed milk 1L',1,charindex(' ','skimmed milk 1L'),'') ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
ramsis
Starting Member
2 Posts |
Posted - 2010-09-18 : 07:32:04
|
many thanx for your help, i highly appreciate that!it worked with me like that:UPDATE dbo.tblstsabitSET stok_adi=right(stok_adi,len(stok_adi)-(charindex(' ',stok_adi)-1))but now there are ' 'spaces left before. is there a function like 'trim()' in SQL Server2005? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-09-18 : 07:36:18
|
LTRIM(right(stok_adi,len(stok_adi)-(charindex(' ',stok_adi)-1))) No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-18 : 08:59:11
|
quote: Originally posted by ramsis many thanx for your help, i highly appreciate that!it worked with me like that:UPDATE dbo.tblstsabitSET stok_adi=right(stok_adi,len(stok_adi)-(charindex(' ',stok_adi)-1))but now there are ' 'spaces left before. is there a function like 'trim()' in SQL Server2005?
you've LTRIM and RTRIM for trimming leading as well as trailing spaces------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|