I am sure you would have faced and solved it in your way, So I am requesting you to reveal a good way to handle the mentioned problem in .net.
When we use fixed size data-type like Char(5) in SQL and store less characters, while accessing it put blank spaces also. How to handle it?
Please don't suggest me to use only required no of chars in DB. I have a valid reason/requirement for future enhancement.
Loading


Posted May 30, 2011, 7:57 PM EDT
Suppose , if you are restricted to use only, char(5). while fetching the data , you have to use trim function to remove the unwanted space in it.
But the better approach is use varchar instead of char datatype.
Jiteendra SampathiraoRank #585 · 4.1K reputationPosted May 30, 2011, 10:27 PM EDT
Using varchar is always the best option. when you retrieve from database use the built-in functions to get the required shape of the value.
And one more choice is do the validations in UI page when you enter the values into database.
Mark it as Answer if any forum post is helped you...correct answer might help others..
Anil KumarRank #367 · 6.8K reputationPosted May 31, 2011, 1:03 AM EDT
Is there are other techniques also?
Posted May 31, 2011, 1:06 AM EDT
The best approach is use varchar instead of char datatype.
Because if you use trim function , it is another overhead because in all the SPs,views you may have to implement the trim functions.