PDC_REPORT_CreazioneDB/sql/Produzione/funzioni/C6Mart_getAppellativo.sql
2025-06-10 16:47:41 +02:00

31 lines
836 B
Transact-SQL

-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date, ,>
-- Description: <Description, ,>
-- =============================================
CREATE FUNCTION [C6Mart].[getAppellativo]
(
-- Add the parameters for the function here
@Sesso varchar(1),
@Cod_fiscale varchar(16)
)
RETURNS VARCHAR(150)
AS
BEGIN
-- Declare the return variable here
DECLARE @Appellativo VARCHAR(150)
IF(LEN(@Cod_fiscale) = 16 AND CHARINDEX('@',@Cod_fiscale) = 0)
BEGIN
IF(@Sesso = 'F')
--SET @Appellativo = 'Gent. Sig.ra'
SET @Appellativo = 'Gentile signora'
ELSE
--SET @Appellativo = 'Egr. Sig.'
SET @Appellativo = 'Gentile signore'
END
ELSE
--SET @Appellativo = 'Spett.le'
SET @Appellativo = 'Spettabile'
-- Return the result of the function
RETURN @Appellativo
END