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

running a sql server management studio express query from a script


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

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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