If you are talking about MS SQL Server, Why execute DML / DLL commands when it provides awesome front end GUI tool? But yes for practise, you can write the SQL in a .sql file and execute it. Google it for details... i've only used the GUI.
actually i want to use the command line interface to run the query statement. And i dont know how to configure it on my PC to run the command line interface. I googled it but all in vain.