declare @myTable table (
id int identity primary key not null,
foo varchar(100) not null
)
insert into @myTable values('abc|def')
insert into @myTable values('abc|def|')
insert into @myTable values('abcd|efgh')
insert into @myTable values('abcd|efgh|ij|kl')
--select values with one pipe
select foo from
@myTable
where (LEN(foo) - LEN(REPLACE(foo, '|' ,'')))=1
--update values with one pipe(syntax for sql server 2005 or 2008)
update @myTable set foo='new value'
from @myTable
where (LEN(foo) - LEN(REPLACE(foo, '|' ,'')))=1
--modified result
select foo from
@myTable