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.
Microsoft SQL ServerMicrosoft SQL Server 2008SQL

Avatar of undefined
Last Comment
Amour22015

8/22/2022 - Mon
SOLUTION
chaau

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Scott Pletcher

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Vitor Montalvão

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.
SQLCMD-mode.PNG
You can even save that script and call it from command prompt using the SQLCMD utility:
SQLCMD -E -dDatabaseName -ic:\Scripts\MainScript.sql
Amour22015

ASKER
I should have mentioned that all I want to do is SAVE all scripts into one.
Vitor Montalvão

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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Amour22015

ASKER
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
Vitor Montalvão

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Amour22015

ASKER
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
Vitor Montalvão

Once again:
"Chaau's solution is to run in command prompt (DOS)." not in SQL Server Management Studio (SSMS).
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Amour22015

ASKER
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.
Amour22015

ASKER
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?