Why Iam getting this error while iam inserting data through stored procedure. Any thing is wrong here
Error:
The INSERT statement conflicted with the CHECK constraint "CK__Master_Adm__role__7E6CC920". The conflict occurred in database "samp", table "dbo.Master_Admin", column 'role'.
I have table, the table structure is like
CREATE TABLE Master_Admin
(
mstr_id int primary key identity(1,1),
login_UserName varchar(30) not null unique,
login_pass varchar(20) not null,
role char(20) check(role in ('SuperAdmin','Admin','EndUser')) not null,
)
And iam inserting values into this table through storedprocedure and structure of SP is like
create procedure Master_Admin_Insert(
@login_uname varchar(30),
@login_pwd varchar(20),
@role char(20)
)
as
begin
insert into Master_Admin(
login_UserName,
login_pass,
role
)
values
(
'@login_uname',
'@login_pwd',
'@role'
)
end
Execution of Procedure
declare @login_uname varchar(30),
@login_pwd varchar(20),
@role char(20)
set @login_uname='sai'
set @login_pwd='sai123'
set @role='EndUser'
exec Master_Admin_Insert @login_uname,@login_pwd,@role