USE [Vertragsverwaltung_20160404] GO /****** Object: UserDefinedFunction [dbo].[get_applobject] Script Date: 02.12.2016 09:08:53 ******/ DROP FUNCTION [dbo].[get_applobject] GO /****** Object: UserDefinedFunction [dbo].[get_applobject] Script Date: 02.12.2016 09:08:55 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: -- Create date: -- Description: -- ============================================= CREATE FUNCTION [dbo].[get_applobject] ( -- Add the parameters for the function here @input_guid varchar(255), @input_type int ) RETURNS varchar(1024) AS BEGIN declare @resultat varchar(1024) set @resultat='' declare @appl varchar(255) declare @crlf varchar(2) SET @crlf = char(13) + char(10) if @input_type=1 begin declare xc cursor for select applikation from applikationarchitekturobjectappl where guid=@input_guid open xc fetch next from xc into @appl while @@fetch_status=0 begin set @resultat=@resultat + '- '+@appl+@crlf fetch next from xc into @appl end close xc deallocate xc RETURN @resultat end if @input_type=2 begin declare xc cursor for select datenbank from applikationarchitekturobjectdb where guid=@input_guid open xc fetch next from xc into @appl while @@fetch_status=0 begin set @resultat=@resultat + '- '+@appl+@crlf fetch next from xc into @appl end close xc deallocate xc RETURN @resultat end if @input_type=3 begin declare xc cursor for select sst from applikationarchitekturobjectsst where guid=@input_guid open xc fetch next from xc into @appl while @@fetch_status=0 begin set @resultat=@resultat + '- '+@appl+@crlf fetch next from xc into @appl end close xc deallocate xc RETURN @resultat end if @input_type=4 begin declare xc cursor for select applikation from applikationarchitekturobjectvirt where guid=@input_guid open xc fetch next from xc into @appl while @@fetch_status=0 begin set @resultat=@resultat + '- '+@appl+@crlf fetch next from xc into @appl end close xc deallocate xc RETURN @resultat end RETURN @resultat END GO