MS-SQL: Run a SQL Script on Database Server

by Vivek Gite on March 6, 2008 · 1 comment

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.

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 1 comment… read it below or add one }

1 Faris Zuriekat, M.S January 30, 2009

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’

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 15 + 13 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: