我创建了一个存储过程,它将Firstname和Lastname以及可选的CustomerID作为参数并插入到Customer表中。
Create Procedure Proc_InsertCustomer
@FirstName nvarchar(50),
LastName nvarchar(50),
@CustomerID int=Null As
Begin
Insert Into Customer(FirstName, LastName, CustomerID)
Values
(@FirstName
, @LastName
, @CustomerID)
if(@CustomerID=null)
Set @CustomerID=@@Identity
End