From: Ada on
Hello,

I am running a script against a list of SQL Servers using a DOS Batch file.
The .bat generates one output file per SQL Server instance. I can use the
destination SQL Server names in the output file names, but I can not use the
destination machine names. It brings the lcal machine name and use it on all
the out put files.

Could you tell me how I can achieve that?

set dt=none
set tm=none
for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set dt=%%i%%j%%k
for /F "tokens=5-6 delims=:. " %%i in ('echo.^| time ^| find "current" ') do
set tm=%%i%%j
for /F %%a in (SQL2005servers.txt) do sqlcmd -E -S %%a -d master -i
c:\iSEC\ROG_iSEC-SQLSr_2005_2008_201006220000.sql -Y30 -s "|" -o
c:\iSEC\OUT2005\ROG_SQL_Server_%COMPUTERNAME%_%%a_%dt%%tm%.out

Thanks,

--
Ada
SQL Server DBA
From: John Bell on
On Tue, 29 Jun 2010 19:48:07 -0700, Ada
<Ada(a)discussions.microsoft.com> wrote:

>Hello,
>
>I am running a script against a list of SQL Servers using a DOS Batch file.
>The .bat generates one output file per SQL Server instance. I can use the
>destination SQL Server names in the output file names, but I can not use the
>destination machine names. It brings the lcal machine name and use it on all
>the out put files.
>
>Could you tell me how I can achieve that?
>
>set dt=none
>set tm=none
>for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set dt=%%i%%j%%k
>for /F "tokens=5-6 delims=:. " %%i in ('echo.^| time ^| find "current" ') do
>set tm=%%i%%j
>for /F %%a in (SQL2005servers.txt) do sqlcmd -E -S %%a -d master -i
>c:\iSEC\ROG_iSEC-SQLSr_2005_2008_201006220000.sql -Y30 -s "|" -o
>c:\iSEC\OUT2005\ROG_SQL_Server_%COMPUTERNAME%_%%a_%dt%%tm%.out
>
>Thanks,


Hi

If I read this correctly you are saying that you want the destination
machine name instead of (DOS) environment variable %COMPUTERNAME% but
you already have the instance name which is in %%a added to the
filename?

The environment variabke will always be the machine that you run the
script on.


John
From: Ada on
John,
Yes, you are right.
I guess I need the machine names to be extracted using sqlcmd(probably not
possible), not froma local DOS run.

I'm wondering if machine names can be added to the already produced files'
names.

Thanks,

--
SQL Server DBA


"John Bell" wrote:

> On Tue, 29 Jun 2010 19:48:07 -0700, Ada
> <Ada(a)discussions.microsoft.com> wrote:
>
> >Hello,
> >
> >I am running a script against a list of SQL Servers using a DOS Batch file.
> >The .bat generates one output file per SQL Server instance. I can use the
> >destination SQL Server names in the output file names, but I can not use the
> >destination machine names. It brings the lcal machine name and use it on all
> >the out put files.
> >
> >Could you tell me how I can achieve that?
> >
> >set dt=none
> >set tm=none
> >for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set dt=%%i%%j%%k
> >for /F "tokens=5-6 delims=:. " %%i in ('echo.^| time ^| find "current" ') do
> >set tm=%%i%%j
> >for /F %%a in (SQL2005servers.txt) do sqlcmd -E -S %%a -d master -i
> >c:\iSEC\ROG_iSEC-SQLSr_2005_2008_201006220000.sql -Y30 -s "|" -o
> >c:\iSEC\OUT2005\ROG_SQL_Server_%COMPUTERNAME%_%%a_%dt%%tm%.out
> >
> >Thanks,
>
>
> Hi
>
> If I read this correctly you are saying that you want the destination
> machine name instead of (DOS) environment variable %COMPUTERNAME% but
> you already have the instance name which is in %%a added to the
> filename?
>
> The environment variabke will always be the machine that you run the
> script on.
>
>
> John
> .
>