?
Solved

running a sql server management studio express query from a script

Posted on 2010-09-08
4
Medium Priority
?
748 Views
Last Modified: 2012-05-10
Hi

I have a .sql file that I have to run on a database each day. When I make a new query on the database in sql server management studio express and paste in the contents of my .sql file it runs perfectly.

The question is, can this process be run automatically by a script or similar?
0
Comment
Question by:bergsprekken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Expert Comment

by:shlafrock
ID: 33625035
Have you tried to use SQLCMD in your script?

SQLCMD /?
programm is somwhere in Tools\Binn in  MSSQL folder
0
 

Author Comment

by:bergsprekken
ID: 33625191
Havent tried SQLCMD yet, is that compatible with the same sql syntax that worked in managementstudio?
0
 
LVL 1

Accepted Solution

by:
shlafrock earned 2000 total points
ID: 33625277
You're using SQL on a database, not on managment studio, so yes SQL syntax is the same in both.

Create a bat file with something like :
sqlcmd -i file.sql        // i'm not sure about syntax - try the link below

To run a script every day use Task Scheduler

http://www.databasejournal.com/features/mssql/article.php/3654176/SQL-Server-2005-Command-Line-Tool-SQLCMD--Part-I.htm
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question