咨询一个SQL存储过程的问题
存储过程代码:
--订单信息添加存储过程
ALTER PROCEDURE P_BatchImportOrders
@OutCustomerName nvarchar(20),
@OutCustomerID int,
@OutCompanyIp nvarchar(300),
@OutPackageID int,
@OutproductID int,
@OutGeneratorRoom nvarchar(50),
@OutServerTypeID int,
@OutCpu nvarchar(50),
@OutBandwidth nvarchar(50),
@OutHardDisk nvarchar(50),
@OutMemory nvarchar(50),
@Outprice float,
@OutStaffID int,
@OutTechnology nvarchar(10),
@OutOrderDate datetime,
@OutExpirationDate datetime,
@OutModificationCost float,
@OutRenewalDate datetime,
@OutRenewalStatus int,
@OutRenewalFee float,
@OutRemarks nvarchar(MAX),
@OutEntryPerson nvarchar(20),
@OutOrderID int
as
begin
declare @CustomerID nvarchar(20)
select @CustomerID=CustomerID from Customer where CustomerName=@OutCustomerName
set @OutCustomerID=@CustomerID
begin
if @OutPackageID<=0
begin
insert into Products values(@Outprice,@OutGeneratorRoom,@OutServerTypeID,@OutCpu,@OutBandwidth,@OutHardDisk,@OutMemory)
declare @productID int
select @productID=max(productID) from Products
set @OutproductID=@productID
end
else
begin
set @OutproductID=0
end
insert into TableOrders(CustomerID,PackageID,productID,StaffID,Technology,OrderDate,ExpirationDate,ModificationCost,RenewalDate,RenewalStatus,RenewalFee,Remarks,EntryPerson,state) values (@OutCustomerID,@OutPackageID,@OutproductID,@OutStaffID,@OutTechnology,@OutOrderDate,@OutExpirationDate,@OutModificationCost,@OutRenewalDate,@OutRenewalStatus,@OutRenewalFee,@OutRemarks,@OutEntryPerson,0)
declare @orderid int
select @orderid=max(OrderID) from TableOrders
set @OutOrderID=@orderid
begin
insert into UseCompanyIp(IpAddress,OrderIDs)
values (@OutCompanyIp,@OutOrderID)
insert into CompanyIp(IpAddress,IpState,OrderID)
select SUBSTRING(t.OutCompanyIp, number ,
CHARINDEX('
------解决方案--------------------
',t.OutCompanyIp+'
[解决办法]
',number)-number),1,@OutOrderID
from
(
select @OutCompanyIp OutCompanyIp
)t,master..spt_values s
where s.number >=1
and s.type = 'P'
and SUBSTRING('
[解决办法]
'+t.OutCompanyIp,s.number,1) = '
[解决办法]
'
end
end
end