as if exists(select * from Student where sno=@sno) update student set Sname=@sname,Ssex=@ssex,sage=@sage where sno=@snoelse insert into Student(sno,sname,ssex,sage) values(@Sno,@Sname,@Ssex,@Sage) GO ---你想合並數據可以這樣 insert into #a select (a,b,c) from 表1 union select (b,c,d) from 表2 select * from #a drop table #a
--==Create Date:2005/03/19
--===modify by talntlee 2005/02/24
--==Use:插入一個數據
--==Exec Insert_Student 99,'','',2CREATE PROCEDURE Insert_Student
@Sno varchar(50),
@Sname nvarchar(50),
@Ssex nvarchar(50),
@Sage varchar(50)
as
if exists(select * from Student where sno=@sno)
update student set Sname=@sname,Ssex=@ssex,sage=@sage where sno=@snoelse
insert into Student(sno,sname,ssex,sage) values(@Sno,@Sname,@Ssex,@Sage)
GO
---你想合並數據可以這樣
insert into #a
select (a,b,c) from 表1 union
select (b,c,d) from 表2
select * from #a
drop table #a