filmov
tv
Converting numbers to strings in SQL Server: STR and FORMAT functions
![preview_player](https://i.ytimg.com/vi/TiYZRVLZjj4/sddefault.jpg)
Показать описание
In this video, we will be looking at how to convert numbers to strings in SQL Server.
My SQL Server Udemy courses are:
----
My Excel for PC courses are:
----
You can't join a string to a number using the + sign, as SQL Server would try to convert the string to a number, rather than the other way round - you would probably get an error.
Instead, you need to convert the number to a string first, and then you can join two strings together.
There are two main functions to consider. STR converts a number to a string, and you can specify the total length and the number of decimal places. The FORMAT function gives you a lot of customisation, including locale-aware formatting (using the .NET framework formatting patterns and culture).
My SQL Server Udemy courses are:
----
My Excel for PC courses are:
----
You can't join a string to a number using the + sign, as SQL Server would try to convert the string to a number, rather than the other way round - you would probably get an error.
Instead, you need to convert the number to a string first, and then you can join two strings together.
There are two main functions to consider. STR converts a number to a string, and you can specify the total length and the number of decimal places. The FORMAT function gives you a lot of customisation, including locale-aware formatting (using the .NET framework formatting patterns and culture).