0
我有一個將數據插入表中的SQL Server存儲過程2008年存儲過程返回空
這裏是我的存儲過程:
ALTER PROCEDURE [dbo].[RegisterOnline_Insert]
[email protected] int,
@SiteID as varchar(50),
@CustName as varchar(100),
@Address as varchar(255),
@Phone as varchar(20),
@HP as varchar(20),
@Email as varchar(100),
@Description as varchar(500),
@IsValid as bit
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
DECLARE @House as numeric(10,0)
DECLARE @Fibernode as varchar(50)
DECLARE @ftax as numeric(5,0)
DECLARE @Demographics2 AS VARCHAR(50)
DECLARE @PostalCode as varchar(10)
DECLARE @InputBy as varchar(50)
DECLARE @addr as varchar(max)
DECLARE @addrid as int
SET @InputBy = '[Website]'
SET @addr = dbo.udf_StripHTML(@Address)
SELECT @PostalCode = postal_code,
@ftax = ftax,
@Fibernode = fibernode,
@Demographics2 = demographics2,
@addrid = Address_id
FROM dbo.TEMP_HOUSE_INFO2_SITE
WHERE site_id = @SiteID
SET NOCOUNT ON;
INSERT INTO tbMynetOrder(
OrderType,
SITE_ID ,
AddressID,
House,
Cust,
CustName,
Address,
PostalCode,
Fibernode,
PhoneOld,
Phone,
HPOld,
HP,
Email,
ftax,
BoD,
ContactPerson,
IDCard,
PaymentMethod,
Description,
SalesCode,
SchedDate,
SchedTimeID,
Complete,
InstallationCost,
Source,
Covered,
CCIssueBy,
CCType,
CCNo,
CCExpireDate,
CCHolderName,
CCHolderPhone,
CCFrequency,
CCPromoService,
CCAmount,
Demographics2,
SCA,
BlackList,
InputBy,
InputDate
)
VALUES(
1, -- Order Type
@SiteID,
ISNULL(@addrid,0), -- Site ID
null, -- House
null, -- Cust
UPPER(@CustName), -- Customer Name
@addr, -- Address
@PostalCode, -- PostalCode
@Fibernode, -- FiberNode
@Phone, -- PhoneOld
null, -- Phone
@HP, -- HP Old
@HP, -- HP
@Email, -- Email
@ftax, -- ftax
null, -- BOD
null, -- Contact Person
null, -- ID Card
null, -- Payment Method
@Description, -- Description
null, -- Sales Code
null, --SchedDate
null, -- SchedTimeID
null, -- Complete
null, -- InstallationCost
3, -- Source , 3 = Website
@IsValid, -- Covered
null, -- CCIssueBy
null, -- CCType
null, -- CCNo
null, -- CCExpireDate
null, -- CCHolderName
null, -- CCHolderPhone
null, -- Frequency
null, -- CCPromo
null, -- CCAmount
@Demographics2, -- Demographics2
null, -- SCA
null, -- Blacklist
@InputBy, -- Inputby
GETDATE() -- Input Date
)
END
我有我的@SiteID
參數值的問題,當過程中得到一定的價值,它的價值並給予結果:
SELECT @PostalCode = postal_code,
@ftax = ftax,
@Fibernode = fibernode,
@Demographics2 = demographics2,
@addrid = Address_id
FROM dbo.TEMP_HOUSE_INFO2_SITE
WHERE site_id = @SiteID
但是當插入到表中,該值成爲零,爲什麼^ h appens?我的插入語句有問題嗎?
在桌子上是否有INSERT觸發器?也許這是將值設置爲NULL? – DeanOC
@DeanOC ahhh我的壞,我從其他人處理項目,他沒有告訴我有關觸發器,謝謝你給我一個插入觸發器的東西:) – Sabilv