hi ...
i m a new member
i want a help on this query(new user of sql :D )
yaa and the query is
create a rule and attach it to the service_code(column) of airline_service(Table) alow only the values 'cc','n' and 'wc' to be entered into the column
plz tell mee... :confused: ..i wlll be gr8 fulllllllllllllllllllllllllllllllll ;)I suggest you to create a CHECK CONSTRAINT instead of a rule:
ALTER TABLE dbo.airline_service
ADD CONSTRAINT chk_servicecode CHECK (service_code IN ('cc', 'n', 'wc'))
Davide Mauri
http://www.davidemauri.it|||You could create a trigger or a check. I think a check is more likely what you'd like, fe:
use monkey
go
create table table1 (mycolumn varchar(10))
go
alter table table1 with check
add constraint df__myrule check
( mycolumn not in ('yes', 'allowed'))
go
insert into table1 (mycolumn) values ('yes')
insert into table1 (mycolumn) values ('no')
go
select *
from table1
drop table table1
go
See BOL on CHECK
EDIT: sniped!|||thank youuuuuuuuuuuuuuuuuuuuuuu :o|||I hope your professor gives you full credit for that, but next time try to do your own homework first.|||I doubt if the Professor will give a credit!
He asked for a rule so it should be:
CREATE RULE list_rule
AS
@.list IN ('cc', 'n', 'wc')
nomis|||That's for sure, but rules are to be considered deprecated, only for backward compatibility. So the CHECK solution is really better. :-)
Anyway, after adding the rule it must be binded with sp_bindrule
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment