Andrea Montanari
hi,
SqlCMD accepts dynamic variable replacement providing variable's value even from the outside..
say you have a script file to be executed like
[file.sql]
DECLARE @path varchar(128);
SELECT @path = '$(path)';
SELECT @path AS [your output path];
[/file.sql]
you can call SqlCmd providing the path variable value to be used inside the Transact-SQL code of the file..
so you can call SqlCMD like:
c:\..\>SqlCMD -S.\SQLExpress -E -v path = "c:\myfolder\" -i c:\file.sql >c:\output.txt
and "c:\myfolder\" will be used inside the script as the $(path) variable's value..
at install time, you'll probably call SqlCMD interactively inside your installer package, and as long as you have the folder you like to use, you can pass it to SqlCMD as well very simply..
just bear in mind this only works locally to the machine you installed SQLExpress on, as, for instance, you can not use this scenario from remote connections, as SqlCMD could not be installed on that remote machines..
regards