代码
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
alter PROCEDURE [dbo].PROG_Order_Main_GetNextPre
@OrderID nvarchar(30),
@type int
AS
BEGIN
declare
@result table(
id int identity(1,1),
OrderID nvarchar(30) not null
)
declare
@select nvarchar(400),
@id int
insert into @result select OrderID from dbo.Order_Main order by AddTime desc
--1上一条
--2下一条
select @id=id from @result where OrderID=@OrderID
if(@type=1)
set @id=@id-1
else
set @id=@id+1
select OrderID,AddTime,OrderType,Price_order from Order_Main where OrderID=(select OrderID from @result where id=@id)
END
GO
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
alter PROCEDURE [dbo].PROG_Order_Main_GetNextPre
@OrderID nvarchar(30),
@type int
AS
BEGIN
declare
@result table(
id int identity(1,1),
OrderID nvarchar(30) not null
)
declare
@select nvarchar(400),
@id int
insert into @result select OrderID from dbo.Order_Main order by AddTime desc
--1上一条
--2下一条
select @id=id from @result where OrderID=@OrderID
if(@type=1)
set @id=@id-1
else
set @id=@id+1
select OrderID,AddTime,OrderType,Price_order from Order_Main where OrderID=(select OrderID from @result where id=@id)
END
GO