Adding whitespace in Java

I think you are talking about padding strings with spaces. One way to do this is with string format codes. For example, if you want to pad a string to a certain length with spaces, use something like this: String padded = String.format(“%-20s”, str); In a formatter, % introduces a format sequence. The – means … Read more

How to use a TRIM function in SQL Server

You are missing two closing parentheses…and I am not sure an ampersand works as a string concatenation operator. Try ‘+’ SELECT dbo.COL_V_Cost_GEMS_Detail.TNG_SYS_NR AS [EHP Code], dbo.COL_TBL_VCOURSE.TNG_NA AS [Course Title], LTRIM(RTRIM(FCT_TYP_CD)) + ‘) AND (‘ + LTRIM(RTRIM(DEP_TYP_ID)) + ‘)’ AS [Course Owner]

How can I configure Entity Framework to automatically trim values retrieved for specific columns mapped to char(N) fields?

Rowan Miller (program manager for Entity Framework at Microsoft) recently posted a good solution to this which uses Interceptors. Admittedly this is only valid in EF 6.1+. His post is about trailing strings in joins, but basically, the solution as applied neatly removes trailing strings from all of the string properties in your models, automatically, … Read more