日期:2014-05-16 浏览次数:20719 次
declare @A1 bigint
declare @BStep bigint
set @A1 = 268435455
set @BStep = 268435456
declare @indextable table([id] [bigint] IDENTITY(@A1,@BStep) NOT NULL, [nid] [bigint] NULL)
CREATE PROCEDURE [dbo].[mypcAddProCategory]
(
@PcPID bigint,
@PdName nvarchar(300),
@A1 bigint,
@A2 bigint,
@BStep bigint
)
AS
set nocount on
begin
declare @sql varchar(8000)
declare @t table(newPCID bigint)
set @sql = '
declare @newPCID bigint
set @newPCID = 0
declare @indextable table([id] [bigint] IDENTITY('+
CAST(@A1+1 as varchar)+','+CAST(@BStep as varchar)+'
) NOT NULL, [nid] [bigint] NULL)
insert into @indextable(nid) SELECT PcID FROM ProCategory WHERE (PcID >
'+CAST(@A1 as varchar)+
') AND (PcID <= '+CAST(@A2 as varchar)+') AND (PcPID = '+CAST(@PcPID as varchar)+
') ORDER BY PcID
SELECT TOP 1 t.id
FROM @indextable t
WHERE t.id <> t.nid
ORDER BY t.id
'
--select @sql
insert into @t
exec(@sql)
declare @newPCID BIGINT
select @newPCID = newPCID from @t
print @newPCID
end
set nocount off
go