Link to home
Create AccountLog in
Avatar of Amour22015
Amour22015

asked on

SQL Server 2008 R2 - All Script Into One

Hi Experts,

This is more of a knowledge based question.

I have about 5 scripts that I would like to save as only one script, can someone help me?

Thanks for your help.
SOLUTION
Avatar of chaau
chaau
Flag of Australia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
If you want to run all the scripts in a preferred order then I'll recommend you to turn on the SQLCMD mode in SSMS and use the :r command to call the scripts.
User generated image
You can even save that script and call it from command prompt using the SQLCMD utility:
SQLCMD -E -dDatabaseName -ic:\Scripts\MainScript.sql
Avatar of Amour22015
Amour22015

ASKER

I should have mentioned that all I want to do is SAVE all scripts into one.
I think everyone understood what you want and Chauu gave you a good solution to achieve that but ScottPletcher alerted you for some issues that can happen with that solution so I gave you another option to accomplish that by running all scripts each one within their own context so you can avoid the issues that you was alerted to.
I would be grateful to have this kind of support from experts.
I am grateful to have support from experts

I am knew to all this.

I thought there was an easy solution.

One of my co-workers did it so easy the last time but I forgot how to do this and don't want to ask him again.  It seems that what he did was not so complicated.

Lets make sure we are talking about the same thing?

When I save One script I do:
File>Save All
but that saves only one at a time.

I want to save all the scripts I have up in the window(s) into one so co-worker can take that script and move it into live.

I tried Chauu  and got error "Incorrect syntax near '*'.

Please help and thanks
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I noticed that under "copy" it says: could not find stored procedure 'Copy'

Also I was told to make sure and take out all the "USE" out of each SPR.

Thanks for any help
Once again:
"Chaau's solution is to run in command prompt (DOS)." not in SQL Server Management Studio (SSMS).
This is what I am looking for but I don't remember my co-worker doing that.  I will see when he goes to bring that script into live.  Thanks for helping me.  Wanted to let you all know that I am grateful to have support from experts and am not trying to disagree only trying to understand.
Vitor,
Once again:
"Chaau's solution is to run in command prompt (DOS)." not in SQL Server Management Studio (SSMS).

I started working in computers in 1984 so I know about the DOS prompt but seems like technology has gone past me lately.  What I learn today is gone tomorrow, we should have all been paid like doctors?