Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Handy trick : Concatenate SQL Files
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Merkin
Funky Drop Bear Fearing SQL Dude!

Australia
4970 Posts

Posted - 08/11/2002 :  01:45:05  Show Profile  Visit Merkin's Homepage  Reply with Quote
Hi all. Here is a little trick I came up with the other day. Although a bunch of yu may have already thought of it, I thought I might share it.

I had a directory with about 30 .sql files in it (each one a Create Procedure statement). I needed to deploy all the files to a live database. Being the incredibly lazy person I am I didn't want to open up each file and run it.

So, I dropped into DOS, went to that directory and typed


type *.sql > newfile.sql


This created a new file that contained all of the other files, I could just run that file in query analyzer and I was done.

Give it a try!

Damian

VyasKN
SQL Server MVP & SQLTeam MVY

United Kingdom
313 Posts

Posted - 08/11/2002 :  05:46:21  Show Profile  Visit VyasKN's Homepage  Reply with Quote
Funny you should mention it, I did the same thing on Friday for a deployment :-) Of course, I had to test the new script file on a test database, just to be sure everything is in place.

--
HTH,
Vyas
http://vyaskn.tripod.com
Go to Top of Page

jasper_smith
SQL Server MVP & SQLTeam MVY

United Kingdom
846 Posts

Posted - 08/11/2002 :  10:54:10  Show Profile  Visit jasper_smith's Homepage  Reply with Quote
I actually wrote a stored procedure to do this ( for some reason I write everything in TSQL - its a sickness) so that the formating looked okay. Since numerous developers write the procedures not evryone (including me) puts hard returns at the bottom of the scripts so when concatenated the last line of procedure 1 flows into the first line of procedure 2 which looks a bit ugly - it also allows me to add a header of who created the run script and the date .


HTH
Jasper Smith
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

Australia
4970 Posts

Posted - 08/11/2002 :  11:02:07  Show Profile  Visit Merkin's Homepage  Reply with Quote
There is a great tool provided with Ken Henderson's recent book that will build an SQL file out of a folder in VSS. But I was in a hurry and didn't want to install it.

This was is quick and dirty, and I'm all for that

Damian
Go to Top of Page

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 08/12/2002 :  07:30:06  Show Profile  Visit nr's Homepage  Reply with Quote
see
http://mysite.freeserve.com/root/
Administering SQL Server Release Control
6.1 Creating the scripts

The next version of this document (which I may never get round to completing) does it all from t-sql using osql to release the version.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

Australia
4970 Posts

Posted - 08/12/2002 :  07:40:41  Show Profile  Visit Merkin's Homepage  Reply with Quote
yeah.....but....... man.....

type *.sql > newfile.sql




Damian
Go to Top of Page

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 08/12/2002 :  08:52:48  Show Profile  Visit nr's Homepage  Reply with Quote
exec master..xp_cmdshell 'osql -Q"exec master..xp_cmdshell ''type \\MyPC\Share\testosql\*.sql > c:\osqlcmds.txt''"'
exec master..xp_cmdshell 'osql -i"c:\osqlcmds.txt"'

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2019 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000