timlash
timlash

Reputation: 89

SQL Server Data Precedence

This resource documents outcomes from implicit data conversion for MS SQL Server. Unfortunately, this list omits the Numeric data type. Can someone confirm that the Numeric type falls in line with the closely related Decimal type? My immediate need is to confirm that Numeric slots above the Money data type. Thanks.

Upvotes: 0

Views: 76

Answers (2)

userfl89
userfl89

Reputation: 4810

Similar to decimal, numeric does have a higher data precendence than money. The following returns numeric as the result.

DECLARE @num NUMERIC
DECLARE @money MONEY

SET @num = 99.99
SET @money = 99.99

SELECT SQL_VARIANT_PROPERTY(@num + @money,'BaseType') as DataType

Upvotes: 2

squillman
squillman

Reputation: 13641

From the docs:

Decimal and numeric are synonyms and can be used interchangeably.

https://learn.microsoft.com/en-us/sql/t-sql/data-types/decimal-and-numeric-transact-sql?view=sql-server-2017

They are not merely closely related, they are the same thing from SQL Server's perspective and thus have the same conversion precedence.

Upvotes: 2

Related Questions