<p>I have a number of generated .sql files that I want to run in succession.  I'd like to run them from a SQL statement in a query (i.e. Query Analyzer/Server Management Studio).<br>
Is it possible to do something like this and if so what is the syntax for doing this?</p>

<p>I'm hoping for something like:</p>

<pre><code>exec 'c:\temp\file01.sql' 
exec 'c:\temp\file02.sql'
</code></pre>

<p>I am using SQL Server 2005 and running queries in management studio.</p>

use
xp_cmdshell
and
sqlcmd
```
```
EXEC xp_cmdshell  'sqlcmd -S ' + @DBServerName + ' -d  ' + @DBName + ' -i ' + @FilePathName
```
```