In SQL Server, you can convert an INT to VARCHAR using either the CAST or CONVERT function. Here are both options:
Using CAST
|
|
Using CONVERT
|
|
Key points
Always specify the length for VARCHAR (e.g., VARCHAR(10)), otherwise SQL Server uses a default length of 30.
If you omit the length, it might cause truncation or unexpected results in some contexts.
Documentation
Reference: Microsoft Learn.