Here is another intersting tweet from What Developers Need to Know About SQL Server:
@BrentO @SQLRich Stop parsing strings, splitting lists and formatting dates in T-SQL. There are much more efficient ways to do these things.
— Aaron Bertrand (@AaronBertrand) October 24, 2013
What Aaron is talking about here is that SQL is a Query Language – that is what SQL and relational databases are optimized for – getting result sets.
SQL is not a data manipulation language – yes, you can do quite a lot of manipulation of string, dates and such, but the language does not lend itself to such operations.
It is far more efficient to move such operations to the client/UI code – whatever language you use to interact with the database will almost certainly have better facilities for manipulating strings and dates.
So, could you tell us, what is these efficient ways? share us a link or give us more details. Thanks @odedcoster :)
There are too many scenarios to list – one example would be to parse out the specific portions from a varchar column (say you have some semi-structured data in it) – SQL (the standard) does not have efficient facilities do that (some databases have non-standard extensions that do).
Fetching the whole field and looping over the results and parsing them out using regular expressions (for example) could be far more efficient.