echo. set /p db=Enter your database name and press Enter. set /p path=Enter the path to your backup file (add a backslash to the end) and press Enter. osql -E -S.\ESC -Q "sp_attach_db @dbname = N'%db%', @filename1 = N'%path%%db%.mdf', @filename2 = N'%path%%db%_log.ldf'" pause