You are here: Re: Best way to force a varchar column to have no whitespace « MsSQL Server « IT news, forums, messages
Re: Best way to force a varchar column to have no whitespace

Posted by Dan Guzman on 10/02/06 12:26

One method is with a CHECK constraint that checks for the list of your
prohibited characters. You may need to scrub data before adding the
constraint.

ALTER TABLE MyTable WITH CHECK
ADD CONSTRAINT CK_MyTable_MyColumn
CHECK (MyColumn LIKE '%[^' + CHAR(32) + CHAR(13) + CHAR(10) + CHAR(9) +
']%')
WITH CHECK
GO

--
Hope this helps.

Dan Guzman
SQL Server MVP

"metaperl" <metaperl@gmail.com> wrote in message
news:1159777716.594197.268970@e3g2000cwe.googlegroups.com...
>I have a column that I do not want any whitespace in whatsoever. I'm
> wondering how do enforce this a DDL level instead of in 40 million
> seat-of-the-pants after-the-fact computer programs accessing the
> database.
>
> Regards,
> Terrence
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация