USE [Vertragsverwaltung_20160404] GO /****** Object: StoredProcedure [dbo].[sp_vertragselement_check_parent_child] Script Date: 02.12.2016 09:08:53 ******/ DROP PROCEDURE [dbo].[sp_vertragselement_check_parent_child] GO /****** Object: StoredProcedure [dbo].[sp_vertragselement_check_parent_child] Script Date: 02.12.2016 09:08:55 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create PROCEDURE [dbo].[sp_vertragselement_check_parent_child] @vertragselementnr int, @anzahl int output AS BEGIN select @anzahl = parentid from Vertragselement where Vertragselementnr=@vertragselementnr if @anzahl > 0 return select @anzahl=COUNT(*) from Vertragselement where ParentID=@Vertragselementnr return END GO