how to add a user to local sql server when one has only windows admin rights on the server
It's pretty easy to do if you are a member of the local Administrators group.
The below steps are taken from this answer on StackOverflow:
Open a command prompt window. If you have a default instance of SQL Server already running, run the following command on the command prompt to stop the SQL Server service:
net stop mssqlserver

If you're running a named instance of SQL Server, the Service Name will be something similar to mssql$instancename.
Open SQL Server Configuration Manager from the Windows Start Menu.  Find the instance listed in the &quot;SQL Server Services&quot; window, and right-click it, then click &quot;Properties&quot;.  Go to the &quot;Service Tab&quot;, and make note of the &quot;Binary Path&quot; and CD into it as such:
CD &quot;C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Binn&quot;

Run the following command to start SQL Server in single user mode.  As
SQLCMD is being specified, only one SQLCMD connection can be made (from another command prompt window).
sqlservr -m&quot;SQLCMD&quot;

Open another command prompt window as the same user as the one that started SQL Server in single user mode above, and in it, run:
sqlcmd

And press enter. Now you can execute SQL statements against the SQL Server instance running in single user mode.  To add a login for your account, run:
CREATE LOGIN [DOMAIN\USERNAME] FROM WINDOWS;

Replace DOMAIN and USERNAME with appropriate values.
-- For older versions of SQL Server:
EXEC sys.sp_addsrvrolemember @loginame = N'DOMAIN\USERNAME'
     , @rolename = N'sysadmin';

-- For newer versions of SQL Server:
ALTER SERVER ROLE [sysadmin] ADD MEMBER [DOMAIN\USERNAME];
GO

Source.