SQL Server - multiple dml in store procedures..?

Asked By sunil pandey on 20-Mar-12 05:58 AM
hi all

i am writting this but getting field error

create proc panelpros
(@panelcode int,@name varchar(50),@address varchar(100),@description varchar(100),@abc varchar(30))
as
begin
if(abc='panelinsert')

insert into panel values(@name,@address,@description)

end
Web Star replied to sunil pandey on 20-Mar-12 06:10 AM
Field error mean something problem with your insert query may be there some column having wrong spelled and also best way is you shuld specify the column name in which you want to insert the value

change it as

Create proc panelpros
(
@panelcode int,@name varchar(50),@address varchar(100),@description varchar(100),@abc varchar(30)
)

AS
begin
if(abc='panelinsert')
Begin
insert into panel(name, address, description) values(@name,@address,@description)

End
end 

make sure the column name should be correct and the if other column in the table that should allow either null value or having default value

hope this helps you
D Company replied to sunil pandey on 20-Mar-12 06:43 AM
create proc panelpros
(@panelcode int,@name varchar(50),@address varchar(100),@description varchar(100),@abc varchar(30))
as
begin
if(abc='panelinsert')//error

insert into panel values(@name,@address,@description)