TRY_CONVERT // Converting data to date, datetime, datetime2, time

Content Overview Probably the most challenging conversion is the conversion of a date and/or time, which is supplied as text, into a value of type date, time, datetime or datetime2. SQL Server provides the following data types, among others, for storing a date and/or time: To convert a date supplied as text, the CONVERT and … Read more

TRY_CONVERT // Converting data to float, real

Content Overview SQL Server provides the following data types for storing floating point numbers: The data types float and real are not precise data types. They are suitable for storing particularly large or small values, but at the expense of accuracy. This means that a number equal to 0 can apparently be stored, but which … Read more

TRY_CONVERT // Converting data to money, smallmoney

SQL Server provides the following data types for storing currency values: The data type money is essentially identical to the data type decimal(19, 4) and the data type smallmoney to the data type decimal(10, 4). There are internal differences in how SQL Server stores a decimal value and a money/smallmoney value. However, these differences are … Read more

TRY_CONVERT // Converting data to bigint, int, smallint, tinyint

This article describes how to safely convert input values to bigint, int, smallint and tinyint data types. A seemingly simple task, one would think. For example, what happens if you want to convert a decimal number or an empty string to a value of type int. Is the converted value automatically rounded? Does function return … Read more

TRY_CONVERT // Converting data to decimal, numeric

This article describes how to safely convert input values to bigint, int, smallint and tinyint data types. A seemingly simple task, you might think. For example, what happens if you want to convert a decimal number or an empty string to a value of type int. Is the converted value automatically rounded? Does function return … Read more