• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 750
  • Last Modified:

running a sql server management studio express query from a script

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
bergsprekken
Asked:
bergsprekken
  • 2
1 Solution
 
shlafrockCommented:
Have you tried to use SQLCMD in your script?

SQLCMD /?
programm is somwhere in Tools\Binn in  MSSQL folder
0
 
bergsprekkenAuthor Commented:
Havent tried SQLCMD yet, is that compatible with the same sql syntax that worked in managementstudio?
0
 
shlafrockCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now