You are here: Re: Select question « MsSQL Server « IT news, forums, messages
Re: Select question

Posted by matthewf_boi on 03/09/07 21:03

On Mar 9, 12:38 pm, "Chris" <cjscu...@gmail.com> wrote:
> Is there a way to select records that do not contain a certain
> character string in char, vchar or text fields? For example records
> where the email field does not contain the "@" character. Can't find
> it in the BoL.
>
> Chris

CREATE TABLE MYTABLE (COL1 VARCHAR(80), COL2 VARCHAR(80))

INSERT INTO MYTABLE (COL1, COL2) VALUES ('1', 'Bob@bob.com')
INSERT INTO MYTABLE (COL1, COL2) VALUES ('2', 'Bob.com')
INSERT INTO MYTABLE (COL1, COL2) VALUES ('3', 'mary@bob.com')
INSERT INTO MYTABLE (COL1, COL2) VALUES ('4', 'Mary')

SELECT * FROM MYTABLE WHERE CHARINDEX('@', COL2) =0

Charindex is looking for the position # of the character specified.
If the character is not there, the charindex should be zero.

HTH
Matthew

 

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

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