USE [FrontAlma]
GO
/****** Object:  UserDefinedFunction [dbo].[ex_Get_Id_Targ]    Script Date: 08/09/2012 11:04:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO





-- select * from hteltarg
-- Select dbo.ex_Get_Id_Targ('CELULAR')
ALTER  FUNCTION [dbo].[ex_Get_Id_Targ] ( @descripcion varchar(40) )
RETURNS int
AS
BEGIN
   declare @id_targ  int
  
   Select @descripcion = COALESCE(RTRIM(@descripcion),'')

   if @descripcion = ''
      Return NULL

   Select @id_targ = id_targ
    From Hteltarg
    Where descripcion = @descripcion

   RETURN @id_targ
END








