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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Run all .sql files in a given folder?

Author  Topic 

sayeo87
Starting Member

1 Post

Posted - 2008-06-04 : 20:27:19
Hi,

say I have th following in my post-deployment script:

:r ..\ScriptsFolder\Script1.sql
:r ..\ScriptsFolder\Script2.sql
:r ..\ScriptsFolder\Script3.sql
...


How can I do the equivalent of

:r ..\ScriptsFolder\*.sql

??

I've tried the above and the syntax is not supported.

Your help is much appreciated! =)

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2008-06-05 : 01:20:36
I am not aware of any way to do this within sql, however it is fairly easy to write a batch file to accomplish this.
Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2008-06-05 : 07:46:14
!!for %c in ("C:\Documents and Settings\...\ScriptFolder\*.sql") do sqlcmd -S <servername> -i "%c"

Jay
to here knows when
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-06-05 : 10:29:45
this seems dangerous. I hope you have good security on that folder!




elsasoft.org
Go to Top of Page
   

- Advertisement -