SELECT Result = dbo.TrimLeftChar('.','.............Adrian')
Detective Stories - Changing the Case
How to change your "UPPER" or "lower" case strings to a mixed case
2010-10-18
6,063 reads
quibimwe,
2012-08-16 (first published: 2012-08-02)
SELECT Result = dbo.TrimLeftChar('.','.............Adrian')
CREATE FUNCTION [dbo].[TrimLeftChar]( @CharToTrim AS CHAR(1) , @String AS VARCHAR(MAX) ) RETURNS VARCHAR(MAx) AS BEGIN RETURN REPLACE( LTRIM( REPLACE(@String, @CharToTrim,' ')), ' ', @CharToTrim) -- Replace the char to be trimed with spaces. If we want to trim 0 -- '0001234056000' will become ' 1234 56 ' -- Trim the left spaces. ' 1234 56 ' will become '1234 56 ' -- Restore the non trimed spaces with its original value. -- '1234 56 ' will become '1234056000' -- As you can see it only works nice for single text. but i migth useful -- to you in a particular situation. END
How to change your "UPPER" or "lower" case strings to a mixed case
I found something interesting the other day. I was attempting to optimize a very heavy string parsing routine using T-SQL and was having problems. I don’t normally use T-SQL for such heavy string parsing, but this was a special case of a legacy structure that I had to work with, so I had no choice.
2009-08-27
5,504 reads
Learn how you can split a delimited string in a single query using XML with Divya Agrawal.
If a column is normalized, but the user really wants to see the values as a short comma separated list, how can I write a query that produces the list? Concatenating the values in a column would be pretty easy if SQL Server had a concatenate aggregate function, which it doesn't. What's more, for efficiency sake it's important to write the reporting queries without using cursors.
2009-02-09
2,240 reads
It is a simple routine that we all need to use occasionally; parsing a delimited list of strings in TSQL. In a perfect relational world, it isn't necessary, but real-world data often comes in a form that requires one of the surprising variety of routines that Anith Sen describes, along with sage advice about their use.
2008-09-24
5,751 reads