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 |
abacusdotcom
Posting Yak Master
133 Posts |
Posted - 2014-06-18 : 15:02:04
|
Hi Good people.I have challenge converting this PLSQL snippet to TSQL equivalent:REGEXP_REPLACE(text,'(^[[:space:]]|[[:space:]]$)') The above helps trim out white-spaces from a text.Do we have DIRECT conversion of the above in TSQL?AbacusI sign for fame not for shame but all the same, I sign my name. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-06-18 : 15:10:28
|
You can use RTRIM and LTRIM to remove trailing and leading spaces.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-06-18 : 15:18:18
|
T-SQL does not support regular expressions. For trimming leading and trailing spaces you can use LTRIM(RTRIM(text)). You can use regular expressions in the query window in SSMS. |
|
|
abacusdotcom
Posting Yak Master
133 Posts |
Posted - 2014-06-18 : 15:31:36
|
Ltrim and rtrim only remove space.. what about special characters?I sign for fame not for shame but all the same, I sign my name. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-06-18 : 15:38:51
|
quote: Originally posted by abacusdotcom Ltrim and rtrim only remove space.. what about special characters?
You can use the REPLACE function.If you provide some sample data and all of the requirements, we can provide better help.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|