SQL Server Data Type Conversion Methods and performance comparison

SQL Server Data Type Conversion Methods and performance comparison

In this article, SQL Server provides us with a big library of system data types that define all types of data that can be used with SQL Server, from which we can choose the SQL Server data type that is suitable for the data we will store in that object. You can also define your own customized user-defined data type using a T-SQL script. SQL Server data types can be categorized into 7 main categories. When you will define SQL Server database tables, local variables, expressions, or parameters, you should specify what kind of data will be stored in those objects, such as text data, numbers, money, or dates. This attribute is called the SQL Server Data Type

  • Character Strings, such as CHAR and VARCHAR.
  • Unicode Character Strings, such as NCHAR and NVARCHAR.
  • Binary Strings, such as BINARY and VARBINARY.
  • Other Data Types, such as CURSOR, XML
  • Exact Numeric types, such as INT, BIGINT, and numeric.
  • Approximate Numeric types, such as FLOAT and REAL.
  • Date and Time types, such as DATE, TIME, and DATETIME.

 

There are many examples in the below

declare @MNumber int
set @MNumber = 123
select 'My number is ' + CAST(@MNumber as nvarchar(20))

 

 

2020-05-05