Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
SQL
INSERT INTO [new].[dbo].[page2]
           ([Name]
           ,[City]
           ,[State]
           ,[Phone]
           ,[Salary]
           ,[Age]
           ,[Gender])
     VALUES
           (<name,>
           ,<city,>
           ,<state,>
           ,<phone,>
           ,<salary,>
           ,<age,>
           ,<gender,>)
GO

CREATE PROCEDURE dbo.InsertStudentsData
@Name varchar(35),
@City char(15),
@State char(15),
@Phone bigint(10),
@Salary int(15),
@Age Int(2)
@Gender char(20)
@IdentitY int OUTPUT
AS
BEGIN
INSERT Students (Name,City,[State],Phone,Salary,Age,Gender)
VALUES 
(@Name,@City,@State,@Phone,@Salary,@Age,@Gender)
END
SELECT @Identity = SCOPE_IDENTITY();
RETURN @Identity
Posted
Updated 25-May-15 20:43pm
v2
Comments
Member 11586797 26-May-15 1:44am    
SHOWING THIS ERROR

(23 row(s) affected)
Msg 102, Level 15, State 1, Line 12
Incorrect syntax near '<'.
Msg 102, Level 15, State 1, Procedure InsertData, Line 9
Incorrect syntax near '@Gender'.
Msg 137, Level 15, State 2, Procedure InsertData, Line 15
Must declare the scalar variable "@Age".
Msg 137, Level 15, State 1, Procedure InsertData, Line 17
Must declare the scalar variable "@Identity".
Msg 137, Level 15, State 2, Procedure InsertData, Line 18
Must declare the scalar variable "@Identity".
[no name] 26-May-15 2:46am    
Put comma "," after @Age Int(2) and @Gender char(20)

1 solution

The code is missing comma(,) after the variables @Age and @Gender.
Another problem with the code is, you cannot specify column width to data types int and bigint The code should be
CREATE PROCEDURE dbo.InsertStudentsData
@Name varchar(35),
@City char(15),
@State char(15),
@Phone bigint,
@Salary int,
@Age Int,
@Gender char(20),
@IdentitY int OUTPUT
AS
BEGIN
INSERT Students (Name,City,[State],Phone,Salary,Age,Gender)
VALUES 
(@Name,@City,@State,@Phone,@Salary,@Age,@Gender)
END
SELECT @Identity = SCOPE_IDENTITY();
RETURN @Identity
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900