Click here to Skip to main content
15,883,925 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
create procedure spuserdetails
(@Name varchar(50),
@DOB datetime,
@Addr varchar(70),
@phn int,
@Country varchar(50),
@States Varchar(50),
@City varchar(50)
)
As 
Begin
insert into userdetails
values(Name=@Name
DOB=@DOB,
Addr=@Addr,
phn=@phn,
Country=@Country,
States=@States,
City=@City)
end

i have mage a following procedure to insert all the values in userdetails table. but on execution error is coming that:
Msg 128, Level 15, State 1, Procedure spuserdetails, Line 13
The name "Name" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
what is the reason ? why it is not executing?
Posted

1 solution

You have a syntax error. Insert statements must follow this format:

SQL
insert into TABLENAME (FIELD1, FIELD2, ... , FIELDN) values (VALUE1, VALUE2, ... , VALUEN)
 
Share this answer
 
v3
Comments
Rambo_Raja 18-Jun-13 2:14am    
it is still not working..but my syntax of inserting values is not wrong:refer to it:http://www.w3schools.com/sql/sql_insert.asp. After changes told by u :
create procedure spuserdetails
(@Name varchar(50),
@DOB datetime,
@Addr varchar(70),
@phn int,
@Country varchar(50),
@States Varchar(50),
@City varchar(50)
)
As
Begin
insert into userdetails(Name,DOB,Addr,phn,Country,States,City)
values(Name=@Name
DOB=@DOB,
Addr=@Addr,
phn=@phn,
Country=@Country,
States=@States,
City=@City)
end
Same error is coming just check in Sql mgmt studio 2008..
_Damian S_ 18-Jun-13 2:16am    
You haven't completely followed the advice I gave you... You are only half way there. If your syntax was correct, you wouldn't have the error!! ;-)

Here's what you missed:

insert into userdetails(Name,DOB,Addr,phn,Country,States,City)
values(@Name, @DOB, @Addr, @phn, @Country, @States, @City)
Rambo_Raja 18-Jun-13 2:23am    
oops...Sorry dear..u r right..thnk u..;)
_Damian S_ 18-Jun-13 2:30am    
:-D No worries.

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