
/****** Object:  UserDefinedFunction [dbo].[ApiFirstPosition]    Script Date: 06.09.2021 21:19:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE FUNCTION [dbo].[ApiFirstPosition]
(
	@DokId int	
)
RETURNS  int
BEGIN
   DECLARE @res int;
   set @res = ISNULL(
   (
   select  top 1 ID from dbo.PozycjeDokHan where Dokument = @DokId   
   ),0);

   return @res;

END


