Can anybody explain me why SQL Server uses .sql file or can this file be attached/detached ?
It's just the default file extension for SQL scripts. You can double-click it in explorer and SSMS will launch. you can open a .sql file in SSMS and run it
If, I am unable to open the .sql file with SSMS then what we should do?
Try and open the file with notepad.
Another way to open it is to drag the file from windows explorer to SSMS.
Do you mean you get an error message? If so, post the message. SSMS can basically open anything in its text editor though if it is .sql it expects it to contain SQL