But I got the 3154 error as below.
restore database databasename
from disk 'filepath.bak'
with replace
but this gave an error because the database and log files were in use for the exisitng database and had to use the with move command as follows.
restore database databasename
from disk 'filepath.bak'
with move data file to 'file path',
move log file to 'file path',
replace
The database was restored successfully.