I have a store to keep records, I would like to know how I can do it to have values check
but if I do not enter any value have a default
I tried to put them out of the store by doing alter table
but I get an error:
clasula defualt interfiere con clausula check.
create table dulces
(
id int not null,
nombre varchar(20),
tipo varchar(15),
proveedor varchar(20),
fechacaducidad datetime not null,
);
alter table dulces add constraint ck_tipo check(tipo='a' or tipo='b' or tipo='c' or tipo='d')
alter table dulces add constraint df_tipo default 'n/a'
create procedure spInsertDulces(@id , @nombre varchar(20),@tipo varchar(15),@proveedor varchar(20),@fechacaducidad datetime)
as begin
if NOT EXISTS (select* from dulces where id=@id)
begin
insert to dulces(id , nombre ,tipo ,@proveedor ,fechacaducidad)
values(@id , @nombre ,@tipo ,@proveedor ,getdate())
end