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.
| Author |
Topic |
|
cathymomo
Starting Member
10 Posts |
Posted - 2009-03-03 : 13:26:12
|
create table Users(UserNo integer not null,UserFirstName varchar(50) not null,UserLastName varchar(50) not null,UserPhone varchar(20),UserEmail varchar(50) not null,UserOrgNo integer not null,UNIQUE (UserEmail),PRIMARY KEY (UserNo),FOREIGN KEY (UserOrgNo) REFERENCES OrgUnit(Orgno));Hi,I was wondering how to add a constraint to this which would ensure that the email contains the "@" sign.Thanks in advance!!  |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2009-03-03 : 13:30:03
|
Use this test in your constraint:UserEmail like '%@%' CODO ERGO SUM |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-04 : 08:33:52
|
quote: Originally posted by cathymomo create table Users(UserNo integer not null,UserFirstName varchar(50) not null,UserLastName varchar(50) not null,UserPhone varchar(20),UserEmail varchar(50) not null,UserOrgNo integer not null,UNIQUE (UserEmail),PRIMARY KEY (UserNo),FOREIGN KEY (UserOrgNo) REFERENCES OrgUnit(Orgno));Hi,I was wondering how to add a constraint to this which would ensure that the email contains the "@" sign.Thanks in advance!! 
is that only rule you need to enforce for email? i think what you need is to validate and make usre its a valid email. look for CLR function below which performs thishttp://www.mssqltips.com/tip.asp?tip=1672 |
 |
|
|
|
|
|
|
|