• Thanks George.. That script work very well.. But I got an issue.

    I run the SQLCMD for named instances too.. Suppose, when i execute my script again a named instance say "serverA\SQL2K". The below stmt

    sqlcmd -S %1 -E -i "X:\script.sql" -o "X:\%1_scriptout.txt"

    will be executed as

    sqlcmd -S serverA\SQL2K -E -i "X:\script.sql" -o "X:\serverA\SQL2K_scriptout.txt"

    This gives an error because the path "X:\serverA\SQL2K_scriptout.txt" does not exist.

    Thanks!!!