<p>I've got a column in a database table (SQL Server 2005) that contains data like this:</p>

<pre><code>TQ7394
SZ910284
T r1534
su8472
</code></pre>

<p>I would like to update this column so that the first two characters are uppercase. I would also like to remove any spaces between the first two characters. So <code>T q1234</code> would become <code>TQ1234</code>.</p>

<p><strong>The solution should be able to cope with multiple spaces between the first two characters.</strong></p>

<p>Is this possible in T-SQL? How about in ANSI-92? I'm always interested in seeing how this is done in other db's too, so feel free to post answers for PostgreSQL, MySQL, et al.</p>

```
```
update Table set Column = case when len(rtrim(substring (Column , 1 , 2))) < 2 
            then UPPER(substring (Column , 1 , 1) + substring (Column , 3 , 1)) + substring(Column , 4, len(Column)
            else UPPER(substring (Column , 1 , 2)) + substring(Column , 3, len(Column) end
```
```
This works on the fact that if there is a space then the trim of that part of string would yield length less than 2 so we split the string in three and use upper on the 1st and 3rd char. In all other cases we can split the string in 2 parts and use upper to make the first two chars to upper case.