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
 General SQL Server Forums
 New to SQL Server Programming
 Setting limited values

Author  Topic 

matta0990
Starting Member

44 Posts

Posted - 2011-04-22 : 07:44:05
Hi, Im wanting to restrict the users input into a database, e.g, only being able to enter the values (mr, mrs, miss etc...) into the "Title" field.

Is this possible to do when creating the table.

I was thinking summit like

CREATE TABLE Customer
(CustomerID SMALLINT NOT NULL
CONSTRAINT CustomerID__PK PRIMARY KEY,
Title VARCHAR (10) NOT NULL
CONSTRAINT Title (Mr, Mrs, Miss),

summit along those lines

Thank You


M Atkinson

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-04-22 : 07:57:09
CREATE TABLE #Customer
(CustomerID SMALLINT NOT NULL CONSTRAINT CustomerID__PK PRIMARY KEY
,Title VARCHAR (10) NOT NULL CONSTRAINT CK_Title CHECK (Title IN('Mr', 'Mrs', 'Miss'))

)


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

matta0990
Starting Member

44 Posts

Posted - 2011-04-22 : 08:09:03
ahh, thank you. I should have known that.....

M Atkinson
Go to Top of Page
   

- Advertisement -