Input Masking in T-SQL while using Select statement

The situation is, i have a table with a column length 6 of Char data type.
But the data will come with any length, i.e., with 4 chars length or 3 chars length..

For Example,
CatName - Length
Dany - 4 Chars
Sam - 3 Chars
Eltone - 6 Chars

In the above sitation, how can i have the data, while fetching with a common legth?

If you use "select replace(space(6-len(CatName))+CatName),' ','X') from table" you will always get the data with fixed length and padded with 'X'

OutPut will be
XXDany
XXXSam
Eltone

One of my major problem is solved...

Comments

Popular posts from this blog

Network Intrusion Detection using Supervised ML technique

Common mistakes by Interviewer

Keep the system active, to avoid the auto lock