Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««123

LTRIM,RTRIM Expand / Collapse
Author
Message
Posted Tuesday, April 2, 2013 3:26 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 3:49 PM
Points: 39,886, Visits: 36,233
Why do you have data with leading spaces in the tables? Why have you not cleaned that data and removed the leading spaces? (and yes, you will need an LTRIM and hence a poorly performing query to do what you want)


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1438111
Posted Tuesday, April 2, 2013 3:28 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, October 1, 2013 11:59 AM
Points: 38, Visits: 89
You are correct, the data should be clean. But sometimes we have no control on the data and it is provided by third party. All we can do is some defensive programming.
Post #1438113
Posted Tuesday, April 2, 2013 3:30 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 3:49 PM
Points: 39,886, Visits: 36,233
The third party inserted it into your database and you don't have rights to run updates?

In this case, defensive programming = slow queries. If your users are happy to have things running slower than they could, then fine.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1438114
Posted Tuesday, April 2, 2013 3:38 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, October 1, 2013 11:59 AM
Points: 38, Visits: 89
Its not that simple.
The third party provides data, another team loads the data and we use the data to display on front end.
The team that loads the data will need to clean the data, but they do not want to do it and we do not have rights to update the data.




Post #1438119
Posted Monday, August 26, 2013 2:06 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, August 29, 2013 10:41 PM
Points: 8, Visits: 55
L TRIM removes all the white space from the starting of the pattern and R TRIM removes all the white space at the end of the pattern.
Post #1488319
Posted Monday, August 26, 2013 3:45 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 5:04 PM
Points: 2,102, Visits: 3,164
mahavidhya24 (8/26/2013)
L TRIM removes all the white space from the starting of the pattern and R TRIM removes all the white space at the end of the pattern.


Sorry, but that's factually incorrect for SQL Server. For SQL, LTRIM and RTRIM affect only spaces, not all whitespace characters.


SQL DBA,SQL Server MVP('07, '08, '09)

"We came in spastic, Like tameless horses /
We left in plastic, As numbered corpses / ...
Remember Charlie, Remember Baker /
They left their childhood On every acre /
And who was wrong? And who was right? /
It didn't matter in the thick of the fight." : the inimitable Mr. Billy Joel, about the Vietnam War
Post #1488512
Posted Tuesday, August 27, 2013 12:28 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 8:46 PM
Points: 35,218, Visits: 31,676
kk1173 (4/2/2013)
Its not that simple.
The team that loads the data will need to clean the data, but they do not want to do it and we do not have rights to update the data.


Wow. I really feel for you there. I have to stop there because nothing civil would come out of my mouth about such a "team".


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1488566
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse