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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started