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
 Other SQL Server Topics (2005)
 adding a not null constraint in management studio

Author  Topic 

Mehdi
Yak Posting Veteran

64 Posts

Posted - 2008-11-04 : 06:42:49
Hi,
I wanted to add a not null constraint for two of columns in studio management how to add its constraint using studio managemtn?
how to add
not null (column1,column2) to my table in management studio 2005?
thanks

_____________
Mehdi.
software student.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-11-04 : 08:57:42
i don't think you can... but as i do most of the stuff in TSQL maybe someone else knows how.

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.1 out!
Go to Top of Page

shaunc
Starting Member

28 Posts

Posted - 2008-11-04 : 16:35:14
If I understand your goal correctly... You can right-click the table in Management Studio and choose the "Design" option. Each column in the table will have a checkbox where you can set the not null constraint.
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2008-11-04 : 16:42:23
Or, if your goal is that one of the columns can be null as long as the other contains data, but they cannot both be null, then what you want to do is create a CHECK constraint. To do that in SMS, right-click the table, choose Design. Then in the toolbar at the top there is a button that looks kind of like a table grid that is for managing/creating Check Constraints.

You'll use something like (Column1 IS NOT NULL OR Column2 IS NOT NULL)
---------------------------
EmeraldCityDomains.com
Go to Top of Page
   

- Advertisement -