SQL Server provides the REVERSE function to invert the order of the characters in a string. In this article, we will learn how to use REVERSE in SQL Server.
The basic syntax of a REVERSE is as follows:
For this, we will be using docker. This is recommended for more than just using SQL Server. To find how to install docker go here: https://docs.docker.com/engine/install/
Now create a file called
docker-compose.yml and add the following.
version: "3.9" services: db: image: "mcr.microsoft.com/mssql/server" ports: - 1433:1433 environment: SA_PASSWORD: "Your_password123" ACCEPT_EULA: "Y"
Open a terminal and go to the folder the file is located. Then run the following.
If you are looking for another good reference, you can check here: https://docs.docker.com/samples/aspnet-mssql-compose/.
The reverse function is pretty straight forward, we simply reverse any varchar type. Here is the example.
SELECT reverse('hello world') as res;