2.convert or cast function is used for data type conversion, and then "+"is used for character splicing. The converted types can be: char, nchar, varchar, nvarchar, etc.
3. The format of the convert function is: convert(varchar(20), num 1), where varchar is a string with variable length and 20 is the maximum length of the string. The advantage of using varchar is that you can avoid spaces in the results. If spaces are needed, consider using char. The following figure shows the query results.
4. The format of the cast function is: cast(num 1 as varchar(20)). For the data format, see the description in the previous step. The following figure shows the query results.
5. The results of1and 2 are exactly the same. Here, when using the "+"operator for varchar and int, varchar will be automatically converted into int, so two sets of values need to be converted.