sseutil.exe - passing variables

I have not been able to successfully pass variables from the sseutil.exe command line to a sql script file.

For those of you unfamiliar with sseutil.exe, it is a free utility that works with both SQL 2005 and 2000. Download it from here:

http://www.microsoft.com/downloads/details.aspx familyid=fa87e828-173f-472e-a85c-27ed01cf6b02&displaylang=en

The ReadMe.htm file contains this:

  -run <filepath> [<var1>=<val1>[,...]]

     Runs a command file (SQL or extended commands) with the variables provided.

I tried sqlcmd syntax for passing variables as well as other things. Nothing worked. An example of passing variables would be very helpful.

What I want to do is this:

test.sql
use AdventureWorks
go
select count(*) from
ENTER_A_VARIABLE_HERE
go

sseutil -run test.sql ENTER_A_VARIABLE_HERE=HumanResources.Employee



Answer this question

sseutil.exe - passing variables

  • lgbjr

    Hello John,

    you need to mark the variable with _$$(VARIABLENAME). For example,

    select count(*) from _$$(ENTER_A_VARIABLE_HERE)

    then you can execute sseutil -run as you wrote above. FYI, you can run 'sseutil help run' to see more information about the run command.

    HTH

    Antoine
    Visual Studio .NET team

  • Demian Schnaidman

    Here is the complete solution:

    test.sql
    use AdventureWorks
    go
    select count(*) from
    _$$(tableName)
    go

    sseutil -run test.sql tableName=HumanResources.Employee

    Or depending on your circumstances, possibly this (it is actually one line, but it may wrap depending on the width of your window):

    sseutil -run test.sql tableName=HumanResources.Employee -s yourServerName -m


  • sseutil.exe - passing variables