Sometimes I have a SQL Server backup file and I need to find out what version it is so that I know where can I restore the file without having to use trial and error.

Let’s assume the backup file in located at c:\mybackup.bak

1
RESTORE HEADERONLY FROM DISK = 'c:\mybackup.bak'

https://www.sqlservercentral.com/blogs/determine-database-version-from-a-bak-file