Question: I am running the below code and then getting an error message an not sure why? Msg 8101, Level 16, State 1, Procedure spstudentinsert, Line
I am running the below code and then getting an error message an not sure why? Msg 8101, Level 16, State 1, Procedure spstudentinsert, Line 26 An explicit value for the identity column in table 'student' can only be specified when a column list is used and IDENTITY_INSERT is ON.
create proc spstudentinsert ( @studentid int=null, @firstname varchar(30) = null, @lastname varchar(30) = null, @SS# int = null, @GPA int = null ) as begin if @studentid is null throw 50001, 'Missing id',1 else if @firstname is null throw 50001, 'Missing first name',1 else if @lastname is null throw 50001, 'Missing last name',1 else if @SS# is null throw 50001, 'Missing social security number',1 else if @GPA is null throw 50001, 'Missing the GPA',1 else Set identity_insert dbo.student on; insert into student values(@studentid,@firstname,@lastname,@SS#,@GPA) end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
