Hi friends,

Does anyone know how to run all the sql files in a folder without specifying the filenames hardcoded using SQLCMD?

This is what I have till now.
Code:
PRINT 'Running Scripts...'

:On Error exit

:r c:\Scripts\01_CREATE_TABLES.sql
:r c:\Scripts\02_TABLE_INSERTS.sql
:r c:\Scripts\03_CREATE_INDEXES.sql
:r c:\Scripts\04_CREATE_PROCEDURES.sql
:r c:\Scripts\04_CUSTOM_CHANGES.sql
:r c:\Scripts\05_CUSTOM_CHANGES.sql
:r c:\Scripts\06_CUSTOM_CHANGES.sql

PRINT 'Running Scripts Complete'
GO
The filenames are hardcoded here, which I want to replace to get dynamically by querying the filesystem. The files to be executed should be sorted in ascending order.

I need to feed it something like the result of this dos command:
Code:
DIR C:\Scripts\*.sql /B /ON