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 2005 Forums
 Transact-SQL (2005)
 Adding a non-empty constraint to Varchar field

Author  Topic 

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2009-03-13 : 14:53:13
I've been looking around and trying to figure out how to add a non-empty constraint to my email field in SQL 2005. I can't find the syntax on how you'd add that.

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2009-03-13 : 15:46:30
what do you mean non-empty constraint? you mean a NOT NULL constraint?
Go to Top of Page

Bodestone
Starting Member

18 Posts

Posted - 2009-03-13 : 16:07:16
Yest you can specify the column as NOT NULL.

In addition, if you also want to elliminate blank strings then you can add a check constraint:

ALTER TABLE myTable
ADD CONSTRAINT CC_myVarchar CHECK (myVarchar <> '');
Go to Top of Page
   

- Advertisement -