Software Development Network>> SQL Server>> Best way to restrict a varchar field not to contain spaces?
Hi,
is this the best way
ALTER
Is there any other way
Thnx
Thanks Simon
SimonSa wrote:NOT LIKE '% %'
or maybe:
NOT LIKE '% %' AND NOT LIKE '% ' AND NOT LIKE ' %'
SimonSa wrote:What is the reason you need this
Carl M. wrote: Thanks Simon SimonSa wrote: NOT LIKE '% %'It would have to be trimmed first no or maybe: NOT LIKE '% %' AND NOT LIKE '% ' AND NOT LIKE ' %'
SimonSa wrote: NOT LIKE '% %'
No. % can stand for any number of characters, even none. NOT LIKE '% %' would be correct.
Not sure but you can also try NOT LIKE '% %'
Try them both. What is the reason you need this
Best way to restrict a varchar field not to contain spaces?
kjmorford
Eugenia
Thanks Simon
It would have to be trimmed first noor maybe:
NOT LIKE '% %' AND NOT LIKE '% ' AND NOT LIKE ' %'
File system entries. The OS allows them but I want to restrict them. It is also being done in the DAL.ScubaRon
No. % can stand for any number of characters, even none. NOT LIKE '% %' would be correct.
Adam Plocher
Not sure but you can also try NOT LIKE '% %'
Try them both. What is the reason you need this