Q. How do I execute a SQL script (.sql file) on my MS-SQL database server under Windows Sever 2003?
A. You can easily run any .sql file on MS-SQL database server using the Query Analyzer tool.
How can I execute a SQL script (.sql file) on my SQL Server ?
Open the Query Analyzer by visiting Start → Programs → MS SQL Server → Query Analyzer
Once opened, connect to the database that you are wish running the script on.
Next, open the SQL file using File → Open option. Select .sql file.
Once it is open, you can execute the file by pressing F5.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop














{ 5 comments… read them below or add one }
H for host ,d for database , U for user and P for password
EXEC master.dbo.xp_cmdshell ‘isql -Hhostname -ddbname -Uusername -Ppassword -i file’
example
EXEC master.dbo.xp_cmdshell ‘isql -H10.203.420.155 -dmdd3 -Umed -Piddmapis -i c:\upgrade110490.sql’
Just visited the MS SQL ‘How Do I’ site… Just read this article… the burning question is: how do I persuade MS that they need to rethink their product from the bottom up, and present it as a clone of ORACLE so there is a chance of using some flexibility in scripting, procedures, packages etc…
If i am using windows autheication mode then how this appera…
EXEC master.dbo.xp_cmdshell ‘isql -Hhostname -ddbname -Uusername -Ppassword -i file’ ????
Thankss for the info..
@Farhad, @Dinesh
the solution using EXEC master.dbo.xp_cmdshell .. is actually generating a command shell!
A lighter way to do this would be to enable SQLCMDmode using the toolbar button, and then run the command as follows
:R C:\somefolder\mysql.sql
if you like the output to be captured into a text file, run the :out beforehand
:out c:\somefolder\myoutputfile.lst