|
The Czech and slovak language and alphabet has a lot of diacritics (letters with accents) in texts - characters like ěščřžýáíéúů and the characters cannot be usually used for text identificators, especially URL or URI http identificators. Python/Django has slugify function designed to convert any character set to ascii, remove extra spaces and other \s+ characters and replace spaces by minus (hyphen) word separator. I need the same function in T-SQL/MS SQL - but TSQL has no regular expression to clear the data, only a little bit similar patindex. So I created next scalar function for this task using patindex. The function works well also for Spanish/Swedish/German/Norwegian/French and other languages, but I'm sorry, it does not work for arabic/russican/greece or similar unicode characters. Next sample contains slugify conversion for unicode characters with code 32-2048. See alsofor 'Slugify for T-SQL/MS SQL - convert string with diacritic to ASCII code' article MS SQL - find text or command in a stored procedureSpecial stored procedure to find any text inside a source code of all stored procedures in one database/server.Copyright and use this code
The source code on this page and other samples at https://www.motobit.com/tips/
are a free code, you can use it as you want: copy it, modify it, use it in your products, ...
If you use this code, please:
1. Leave the author note in the source.
or
2. Link this sample from you page.
<A Href="https://www.motobit.com/tips/detpg_slugify-tsql/" Title="Encode SQL string to ASCII text separated by hyphen (minus), designed for part od URL/URI string" >Slugify for T-SQL/MS SQL - convert string with diacritic to ASCII code</A> Do you like it? Rate me on LinkedIn |
© 1996 - 2019 Antonin Foller, Motobit Software | About, Contacts