Last post Apr 18, 2017 10:15 PM by oned_gk
Apr 18, 2017 01:49 PM|irodriguezl|LINK
I need to change the name result in a query. The names show up like this Smith~Adam, and I need it like this Smith, Adam. Not sure how to change the format to be last, first (with the space included before the first name). Any help would be greatly appreciated!
Apr 18, 2017 03:04 PM|PatriceSc|LINK
If you just want to replace "~" with ", " see
https://docs.microsoft.com/en-us/sql/t-sql/functions/replace-transact-sql . For example:
SELECT REPLACE(Name,"~"," ,") AS DisplayName FROM YourTable
Edit: by using the ~ character, it seems the intent is basically to store two data inside a single column which is likely a bad idea. I would consider to store this information in two separate columns instead. It might be more flexible (for example if you
want to search a user based on his last name).
Apr 18, 2017 10:15 PM|oned_gk|LINK
SELECT REPLACE(Name,'~',', ') AS Name FROM Table1