-- =============================================
-- Create procedure basic template
-- =============================================
-- creating the store procedure
IF EXISTS (SELECT name
FROM sysobjects
WHERE name = N'GetIdByPos'
AND type = 'P')
DROP PROCEDURE GetIdByPos
GO
CREATE PROCEDURE GetIdByPos (@RecNo As Int, @RowId As Int Output)
AS
CREATE TABLE #Temporal (RecNo Int IDENTITY(1,1),
[RowId] [numeric](6, 0))
Insert
Into #Temporal (rowId)
Select FieldId From Table
Select @RowId = RowId
From #Temporal
Where RecNo = @RecNo
Drop Table #Temporal
GO
Return