--testes: SELECT coluna2 = dbo.rendaCliente1(3); create function dbo.rendaCliente1 (@Codigo int) returns float as begin declare @renda float set @renda = (select top 1 renda from cliente (NOLOCK) where cod = @Codigo); if (select TOP 1 estadoCivil from cliente (NOLOCK) where cod = @Codigo) = 'casado' BEGIN IF exists(select TOP 1 isnull(renda_conjuge,0) from conjuge (NOLOCK) where codCliente = @Codigo) set @renda = @renda + (select TOP 1 isnull(renda_conjuge,0) from conjuge (NOLOCK) where codCliente = @Codigo); end return @renda end
↧
Programação de Function
↧