Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2008-02-26 : 08:43:15
|
| How do I retrieve all rows from a middle_name column that have a character length of <= 2. This table is populated with middle names and middle initials. I want to isolate the middle initials only. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-26 : 08:48:43
|
| Can you post some sample data with expected result?MadhivananFailing to plan is Planning to fail |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-02-26 : 08:49:40
|
| [code]declare @t table( a varchar(10))insert into @tselect 'xxx' union allselect 'yy' union allselect 'z' union allselect 'xyzz' union allselect 'zx' union allselect ''select * from @twhere a like '__' or a like '_' or a like ''[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2008-02-26 : 08:52:09
|
| Some sample data in the middle_name column would be:A.BCCCDDD DDDI want to retrieve only the 1 character fields and ultimately assign a '.' to them so that all single characters are formatted as 'X.' |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-26 : 08:56:15
|
| Select columns from tablewhere col like '[a-zA-Z][.]%'MadhivananFailing to plan is Planning to fail |
 |
|
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2008-02-26 : 09:01:33
|
| Thanks Madhivanan, but that returns all rows with an alpha characters and periods, such as T.E., C., and R.I want to revive only the rows where the middle_name contains 1 character such as A, B, CThanks |
 |
|
|
|
|
|