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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 find spaces between word

Author  Topic 

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2014-11-19 : 07:33:26
Strangely i cannot find an example. Just lead and trail spaces.
I did this but it does seem to work:
where CHARINDEX(' ', m.member_cardNumber) >0
Or with '' or where patindex(' ',m.member_cardNumber) > 0

sz1
Aged Yak Warrior

555 Posts

Posted - 2014-11-19 : 09:11:38
select CHARINDEX(' ', 'm.member_card Number') 'find position'
Result postition 14

select CHARINDEX('_', 'm.member_cardNumber') 'find position'
Result postition 9


We are the creators of our own reality!
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2014-11-19 : 10:53:59
Sorry i don't want to find the position, i just need to know how many records have empty spaces in front, between or at the end.
Thanks.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-11-19 : 11:50:40
WHERE m.member_cardNumber LIKE '% %'

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2014-11-19 : 18:07:06
Ow, it is simple?
Will check it tomorrow.
Thanks.
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2014-11-20 : 04:52:41
Yep, works,
Will also work now with
select * from cognetic_members_card
where patindex('% %',card_cardNumber) > 0
Thanks.
Go to Top of Page
   

- Advertisement -