Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Not inserting values into table

Author  Topic 

devikamesh
Starting Member

2 Posts

Posted - 2011-06-23 : 05:25:40
say i have employee table which has 4 field.
1.empid
2.empname
3.gender
4.DOB
in my visual studio while clicking add employee with all these fields designed it should get inserted into database.
i wrote a stored procedure like this. pls help whether am correct or not.
create procedure prc_addemp(@empid int,@empname varchar(20),@gender varchar(10),@dob date,@status int output)
as
begin
insert into emp(empid,empname,gender,dob) values (@empid ,@empname,@gender ,@DOB)
end
go.
this query has executed.
pls help me.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-06-23 : 05:46:17
the stored procedure looks ok. Except you didn't return any value to the @status

do you get any error when execute the stored procedure ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

devikamesh
Starting Member

2 Posts

Posted - 2011-06-23 : 05:49:39
No i didnt get any errors.
i execute procedure like this.
declare @iRes int
exec prc_addemp 100,'abcd','Female','01-03-1985',@iRes
select @iRes

the record is getting inserted into table but that iRes value showing as NULL.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-06-23 : 10:27:25
quote:
Originally posted by devikamesh

the record is getting inserted into table but that iRes value showing as NULL.

That's because:
quote:
Originally posted by khtan

Except you didn't return any value to the @status


create procedure prc_addemp(@empid int,@empname varchar(20),@gender varchar(10),@dob date,@status int output)
as
begin
insert into emp(empid,empname,gender,dob) values (@empid ,@empname,@gender ,@DOB);

SET @status = ????
end
Go to Top of Page
   

- Advertisement -