我對SQL還不熟悉,所以通過學習來完成。我想用存儲過程填充表格。我的問題是如何調用該過程,以便它被執行並且表被填充。到目前爲止,我已經做到了。如何在SQL Server中調用存儲過程以從另一個表中填充一個表?
ALTER proc [dbo].[MytestTableLoad]
@ID int,
@FirstName varchar,
As
Begin
Set nocount on;
merge dbo.MytestTable2 as target
using (select @ID, @FirstName,@LastName) as source (Id, FirstName, LastName)
on (target.Id=source.Id)
when not matched then
Insert (Id, FirstName, LastName)
values (@Id, @FirstName,@LastName)
;
END
存儲過程缺少@LastName參數聲明。 – 2013-03-19 01:21:32