sql - Formatting varchar data into a certain format -
I need to format data in an SQL column that is currently recorded as:
Z04000002003.7Its desired output will be:
Z04 / 000/002 / 003.7
Each time a user data is Z04000002003.7 Like data enters. The next time the user opens the record, he automatically formats it to display Z04 / 000/002 / 003.7.
If you insert slash on INSERT or UPDATE (when the string is received in the database) or selection If you want, you can do this in TSQL with some strange string expressions:
SUBSTRING (Thestring, 1, 3) + '/' + SUBSTRING (thestring, 4, 6) + '/' + ...
And similarly, but I agree with other respondents that it may be a better architecture to make such a change "close to the user" (UI In, or perhaps business The Numeric logic layer that those slash are actually part of the business case, but the UI looks).
Comments
Post a Comment