Код: Выделить всё
create procedure [dbo].[GetNextNrec]
(
@TableName varchar(44),
@NextNrec varbinary(8) output
)
as
begin
declare @OldNrec varbinary(8),
@SQLString nvarchar(80),
@Params nvarchar(30)
set @SQLString= 'select @OldNrec = max(F$NREC) from ' + TableName
set @Params= '@OldNrec varbinary(8) output'
exec sp_executesql @SQLString,
@Params ,
@OldNrec= @OldNrec output
if (@OldNrec)is null
begin
set @NextNrec = 0x800100000000000F
end
else
begin
set @NextNrec = master.dbo.GalCompAsBinary(master.dbo.BinaryAsGalComp(@OldNrec) + 1)
end
end
