Home Forums SQL Server 2012 SQL 2012 - General Concatenate variable values in the third variable in sqlcmd RE: Concatenate variable values in the third variable in sqlcmd

  • peacesells (6/11/2014)


    :setvar Instance SUBSTRING(@@SERVERNAME,7,3)

    :setvar FolderPath "\\Here\there\where"

    I have two sqlcmd variables that i need to concatenate and store the values in the third variable and use that variable in a query.

    somthing like

    :setvar FullName $(FolderPath)+$(FolderPath)

    how can this be done, i tried a couple methods- don't seem to work- any idea?

    No need to concatenate the sqlcmd scripting variables, just do the concatenation in the query.

    😎

    :setvar PartOne 'first_'

    :setvar PartTwo 'second'

    go

    select char(39) + $(PartOne) + $(PartTwo) + char(39) as full_path

    go

    Results

    full_path

    --------------

    'first_second'