1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
USE [IcarDMS]
GO
/****** Object: UserDefinedFunction [dbo].[bi_VehiculeOption] Script Date: 08/28/2018 20:05:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[bi_VehiculeOption] (@Type char(1), @Emp char(3), @Numero numeric (10,0)) RETURNS char(3000) AS
BEGIN
DECLARE @Resultat char(3000), @Option char(8), @Descrip varchar(50)
DECLARE c_Option CURSOR FOR
SELECT tcVehOpcion.Opcion, tcVehOpcion.Descrip FROM tcVehOpcion WHERE tcVehOpcion.Emp = @Emp AND tcVehOpcion.NumInterno = @Numero AND tcVehOpcion.TipoLinea = 'C'
OPEN c_Option
SET @Resultat = ''
FETCH NEXT FROM c_Option INTO @Option, @Descrip
WHILE @@FETCH_STATUS = 0
BEGIN
IF @type = '1' AND LEN(RTRIM(@Resultat))<> 0
SET @Resultat = rtrim(left(@Resultat,len(RTRIM(@Resultat)))) + CHAR(10)
IF @Type ='1'
SET @Resultat = rtrim(left(@Resultat,len(RTRIM(@Resultat)))) + @Option + rtrim(@Descrip)
ELSE
SET @Resultat = rtrim(left(@Resultat,len(RTRIM(@Resultat)))) + ' [' + RTRIM(@Option) + '] ' + rtrim(@Descrip)
FETCH NEXT FROM c_Option INTO @Option, @Descrip
END
CLOSE c_Option
DEALLOCATE c_Option
RETURN @Resultat
END |
Partager