SQL Server 2005的存储过程 [英] Stored procedure for sql server 2005
问题描述
我有1个表,没有任何字段可作为表1&的主键.对于表2,我使用了empid作为外键.我使用了存储过程来插入数据.表2具有
emp教育的详细信息,包括大学,通过年限等列.我想将表2中的记录插入empid.为此,我想要存储过程.
桌子的详细视图
表1
Empid
名称
地址
mob.no
等
表2
Empid
大学
过世的年份
专业
全部都有3个文本框
我想用empid将所有3个文本框中的记录插入到table2中
为此,我要存储过程& vb.net代码.
提前感谢
I have 1 table having no of fields empid as primary key for table1 & for table 2 i used empid as foreign key.I used stored procedure for insert the data. Table 2 having
emp education details with university,yearof passing etc columns.i want to insert the records in table 2 with empid.For that i want stored procedure.
Deatiled view of table
Table1
empid
name
address
mob.no
etc
Table2
empid
university
year of passing
Major subject
all are having 3 textboxes
i want to insert the record from all 3 text boxes to table2 with empid
For that i want stored procedure & vb.net code.
Thanx in advance
推荐答案
查看输出 [ ^ ]子句.
插入一个表后,您将具有插入另一个表所需的信息.
Look at the OUTPUT[^] clause.
After inserting into one table you have information that is needed to insert into another.
hai
使用此存储过程,并尝试在vb代码中的表中使用插入值.
hai
use this stored procedure and try to use insert values in table in your vb code..
drop procedure sp_insert<br />
go<br />
create procedure sp_insert<br />
@p_ename varchar(50),@p_ecity varchar(50),@p_eid bigint,@p_empedu varchar(50),@p_empuni varchar(50)<br />
as <br />
declare @eid int<br />
begin <br />
insert into empinfo(empname,empcity) values(@p_ename,@p_ecity)<br />
set @eid=@@identity<br />
if(@eid!=0)<br />
insert into empstu(empid,empedu,empuni)values(@p_eid,@p_empedu,@p_empuni)<br />
select @eid<br />
end
试试吧..
我希望这对您有用..
保重....
try it..
i hope this is useful to you..
take care ....
这篇关于SQL Server 2005的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!