can't for the life of me get a check to work
I have a column called SaleOrRent which is char(1). all i want is to make
sure the only value that the column will accept is an S or an R
does this check have to be in the create table statementor can i add it
using the alter table statement?
Thanks
David (crap at SQL)
--
http://www.nintendo-europe.com/NOE/...=l&a=ProdigiousYou can do it either with CREATE or ALTER:
CREATE TABLE Sometable ( ... saleorrent CHAR(1) NOT NULL CONSTRAINT
CK_Sometable_saleorrent CHECK (saleorrent IN ('S','R')))
ALTER TABLE Sometable ADD CONSTRAINT CK_Sometable_saleorrent CHECK
(saleorrent IN ('S','R'))
--
David Portas
----
Please reply only to the newsgroup
--|||Thank you very much, works a treat
David
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:t5Cdnd62y9us82CiRVn-hw@.giganews.com...
> You can do it either with CREATE or ALTER:
> CREATE TABLE Sometable ( ... saleorrent CHAR(1) NOT NULL CONSTRAINT
> CK_Sometable_saleorrent CHECK (saleorrent IN ('S','R')))
> ALTER TABLE Sometable ADD CONSTRAINT CK_Sometable_saleorrent CHECK
> (saleorrent IN ('S','R'))
> --
> David Portas
> ----
> Please reply only to the newsgroup
> --
No comments:
Post a Comment