Здравствуйте, Sinclair, Вы писали:
P.S.
Исследовать поведение автовывода типов удобно при помощи вспомогательной процедуры:
IF OBJECT_ID (N'dbo.Analyse') IS NOT NULL
DROP PROCEDURE dbo.Analyse;
GO
create procedure Analyse(@what sql_variant)
as
begin
print cast(@what as varchar(max))
print
cast(SQL_VARIANT_PROPERTY(@what, 'BaseType') as varchar(max)) +'('+
cast(SQL_VARIANT_PROPERTY(@what, 'Precision') as varchar(max))+ ', ' +
cast(SQL_VARIANT_PROPERTY(@what, 'Scale') as varchar(max)) + ')'
end
go
DECLARE
@foo decimal(19,2) = 41761414.14,
@bar decimal(19,2) = 42183246.61,
@what sql_variant
set @what = @foo / @bar * 100
exec Analyse @what
print cast(41761414.14 as dec(19, 2)) * 100 / cast(42183246.61 as dec(19,2))