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, 11:57 PM
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.
Posted May 31, 2011, 5:06 AM
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.
Anil KumarPosted May 31, 2011, 5:03 AM
Is there are other techniques also?
Jiteendra SampathiraoPosted May 31, 2011, 2:27 AM
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..