触发器,一条SQL语句不能对多个表进行数据操作吧
解决方案 »
- 在Content page 中 弹出对话框
- 真心求助各位高手,十万火急!!!!!
- mvc+ef 数据库和model不对应咋办?
- gridview按品名统计
- 求助,如何让动态添加的控件只在当前操作中显示,下下次不再显示
- 四天问题未能解决,继续:1000分求获取oracle数据乱码问题,顶者有分,已结400分
- access的select count(*) into 语句问题
- 能解释一下吗》?
- 基于flash的在线视频交流问题
- VS中控件与数据库数据的绑定问题!!!
- 在深圳,两个月没发工资了,大家提点意见....
- 网站短信充值,出现The underlying connection was closed: An unexpected error occurred on a receive.的错误
@LastName nvarchar(50),
@AddressLine nvarchar(50),
@AddressLine2 nvarchar(50),
@City nvarchar(50),
@State nvarchar(50),
@PostalCode nvarchar(50),
@Phone nvarchar(50),
@Phone2 nvarchar(50),
@Fax nvarchar(50),
@Email nvarchar(50),
@EndUserTypeID int,
@Password nvarchar(50),
@IsSubscribed bitAS--Start the transaction
BEGIN TRANSACTIONDECLARE @AddressID int
DECLARE @ContactInformationID int INSERT INTO Address
(AddressLine,
AddressLine2,
City,
State,
PostalCode)
VALUES
(@AddressLine,
@AddressLine2,
@City,
@State,
@PostalCode)-- Rollback the transaction if there were any errors
IF @@ERROR <> 0
BEGIN
-- Rollback the transaction
ROLLBACK -- Raise an error and return
RAISERROR ('Error INSERT INTO Address.', 16, 1)
RETURN
END SET @AddressID = @@IDENTITY INSERT INTO ContactInformation
(Phone,
Phone2,
Fax,
Email)
VALUES
(@Phone,
@Phone2,
@Fax,
@Email) -- Rollback the transaction if there were any errors
IF @@ERROR <> 0
BEGIN
-- Rollback the transaction
ROLLBACK -- Raise an error and return
RAISERROR ('Error INSERT INTO ContactInformation', 16, 1)
RETURN
ENDSET @ContactInformationID = @@IDENTITY
-- Next Step
INSERT INTO EndUser
(EndUserTypeID,
FirstName,
LastName,
AddressID,
ContactInformationID,
Password,
IsSubscribed)
VALUES
(@EndUserTypeID,
@FirstName,
@LastName,
@AddressID,
@ContactInformationID,
@Password,
@IsSubscribed)-- Rollback the transaction if there were any errors
IF @@ERROR <> 0
BEGIN
-- Rollback the transaction
ROLLBACK -- Raise an error and return
RAISERROR ('Error INSERT INTO EndUser', 16, 1)
RETURN
ENDSELECT @@IDENTITYCOMMIT