The above error message usually occurs only if there are other processes connected to the database.
Use the below code to see which processes are connected:
The above code will return the process and then you will be able to run.
Use below command to end the process:
Here [xxx] is the SPID (Server Process ID) for the processes that you are trying to kill.
Now, you can run the above statement.