
/****** Object:  StoredProcedure [dbo].[GetRecIdRange]    Script Date: 2/4/2016 5:19:16 PM ******/



DECLARE @sql NVARCHAR(MAX)
select @sql = '
    CREATE PROCEDURE [dbo].[GetRecIdRange] 
    @sequence_name nvarchar(20),
    @range_size bigint, 
    @range_first_value bigint output	
AS                 
BEGIN

DECLARE @range_first_value_output sql_variant;		

EXEC sp_sequence_get_range
@sequence_name 
, @range_size 
, @range_first_value_output OUTPUT ;

SET @range_first_value=CAST(@range_first_value_output AS bigint);

END'

IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='GetRecIdRange') 
BEGIN
EXEC sp_executesql @sql
END