SQL Server 2017 I can't make a procedure Im quite new to this.
Im trying to make a procedure with recovery. But instead of making the procedure. It just recovers a database instead.

Use sde_sql
Go

Create Procedure RecoveryScript
as
    Alter Database SDE_SQL 
    SET Single_User with
    Rollback IMMEDIATE

    use master
    go

    Restore Database SDE_SQL
    FROM DISK = 'C:\Users\HF\Desktop\SQL\SQLDatabaseBackup.bak'
    WITH REPLACE, STATS = 5
First off, the word "GO" is the default batch separator. That tells SQL Server, "Alright, I'm done with this command, and go execute it."

So when you run this:

Create Procedure RecoveryScript
as
    Alter Database SDE_SQL 
    SET Single_User with
    Rollback IMMEDIATE

    use master
    go

    Restore Database SDE_SQL
    FROM DISK = 'C:\Users\HF\Desktop\SQL\SQLDatabaseBackup.bak'
    WITH REPLACE, STATS = 5


What you're really doing is this:

Create Procedure RecoveryScript
as
    Alter Database SDE_SQL 
    SET Single_User with
    Rollback IMMEDIATE

    use master
    go


SQL Server does that, and then thinks you're done, and starts this in a separate command:

Restore Database SDE_SQL
FROM DISK = 'C:\Users\HF\Desktop\SQL\SQLDatabaseBackup.bak'
WITH REPLACE, STATS = 5


If you want to create a stored procedure to restore a database, put that stored procedure in master itself (or in another database, but just not the one that's about to get restored, since you can't kill a connection while still running a query from it.) You won't need any "use database" commands in there at all.

Finally, as long as we're talking about restoring databases, check out sp_DatabaseRestore in the open source First Responder Kit. If you're using Ola Hallengren's excellent maintenance scripts to take your backups, you can just point sp_DatabaseRestore at your backup folder, and it'll automatically restore the newest available backups of your database. (Disclaimer: I'm one of the contributors on the First Responder Kit repo.)