Executing SQL file using SQLCMD command

  • we are using a source codecontrol s/w for all our *.sql files.

    how can i use sqlcmd to pull run all the *.sql files using r: "./fodlername/filename.sql"

    and it gave me an error

    A fatal scripting error occurred.

    Incorrect syntax was encountered while parsing :r .

    the only problem is that, there are 4 users and their working forlder for the sourcecode s/w is going to be different. it is\\domainname\username\filesname

    help would be appreciated

    thanks

    Noli Timere
  • This works for me (albeit in SQL2005):

    SQLCMD -S[server name] -E -r1 -d[db name] -i" \\[machine]\[drivespec]$\foldername\filename.sql"

    Quick and dirty would be to do this for each user.

    -MarkO

    "You do not really understand something until you can explain it to your grandmother" - Albert Einstein

  • If they have rights, Mark's solution would work. Or you could map a constant drive for each user in the login script.

  • By "for each user" I meant: stick this in a single batch file, with a call for each user.

    This would simplify the permission issues Steve pointed out.

    SQLCMD -S[server name] -E -r1 -d[db name] -i"\\[machine]\[drivespec]$\FredFolder\FredFile.sql"

    SQLCMD -S[server name] -E -r1 -d[db name] -i"\\[machine]\[drivespec]$\MonaFolder\MonaFile.sql"

    SQLCMD -S[server name] -E -r1 -d[db name] -i"\\[machine]\[drivespec]$\EarlFolder\EarlFile.sql"

    SQLCMD -S[server name] -E -r1 -d[db name] -i"\\[machine]\[drivespec]$\VivFolder\Vivfile.sql"

    -MarkO

    "You do not really understand something until you can explain it to your grandmother" - Albert Einstein

  • will try. thanks

    Noli Timere

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply