Do not use on any
shared computer
August 29, 2008 02:40pm pdt
 
[x]
Attachment Details

How to Run .SQL scripts in SQL Server Management studio

Tags: Microsoft, SQL server, 2005, Running .SQL scripts in Management studio
Hello,

Iam totally new to SQL Administration and I am assigned with the task of running  something like this.

osql -U sa -****@****  -S &&&&&\sqlexpress -d centers -i "c:\bfd\Centre script file 4003.sql" -o"c:\bfd\log280.txt"

****@****                 :  would be the passowrd
&&&&&\sqlexpress       :  Would be the server Name

Now the script is in  "Centre script file 4003.sql " file.

The task i have been assigned to do is the following.

I need to run the same script in the file "Centre script file 4003.sql "  for a a bunch of different remote servers.

I could do this by running the above command manually for each and every sever but I have to run this in a loop by retriving the the server names are stored in a particular table.

I found this intresting article which lets me do that using a cursor , i.e loop throught the values in the table and execute a sql command.

http://www.sqlservercentral.com/articles/Administering/2629/

but iam not sure how to run a .sql file from the sql server management studio and also output it to a text file just like what the OSQL statement does above.

I woulld have to create a Stroed Procedure to accomplish this task.

Any help would be greatly aappreciated.

Thanks,
Ash










Attachments:
 
Script To Run For Multilple Servers Using Cursor
 
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Microsoft
Question Asked By: Ashwin_shastry
Solution Provided By: EugeneZ
Participating Experts: 2
Solution Grade: A
Views: 80
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by faiga16

Rank: Master

Expert Comment by faiga16:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by Ashwin_shastry
Author Comment by Ashwin_shastry:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by EugeneZ

Rank: Genius

Accepted Solution by EugeneZ:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by EugeneZ

Rank: Genius

Expert Comment by EugeneZ:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628