我有一个tbl_Customers
有两列的表,CustomerID
并且CustomerGroupID
. CustomerID
是标识列。添加新记录时,我希望该CustomerGroupID
值自动默认为该CustomerID
值,除非提供了参数值,在这种情况下应将其设置为参数值。
这是我目前的存储过程(不包括CustomerGroupID
列)
非常感谢 SQL Server 新手的任何帮助!
吉姆
ALTER PROCEDURE [dbo].[sp_AddCustomerUpdateCar]
@CarReg varchar(10),
@CustTitle varchar(8),
@CustFName varchar(15),
@CustSName varchar(20),
@CustCompany varchar(30),
@CustTel1 varchar(15),
@CustTel2 varchar(15),
@CustAddress1 varchar(50),
@CustAddress2 varchar(50),
@CustAddress3 varchar(50),
@CustAddress4 varchar(50),
@CustPostCode varchar(9),
@CustEmail varchar(50),
@CustCredit smallmoney,
@CustCreditExpires datetime,
@CustAccountID int,
@CustSource varchar(50)
AS
INSERT INTO tbl_Customers
(CustTitle,
CustFName,
CustSName,
CustCompany,
CustTel1,
CustTel2,
CustAddress1,
CustAddress2,
CustAddress3,
CustAddress4,
CustPostCode,
CustEmail,
CustCredit,
CustCreditExpires,
CustAccountID,
CustSource)
VALUES (@CustTitle,
@CustFName,
@CustSName,
@CustCompany,
@CustTel1,
@CustTel2,
@CustAddress1,
@CustAddress2,
@CustAddress3,
@CustAddress4,
@CustPostCode,
@CustEmail,
@CustCredit,
@CustCreditExpires,
@CustAccountID,
@CustSource)