• despag (1/26/2011)


    While the follwing example is possible

    :SETVAR DB_NAME_ASSIGN "TEST TEXT"

    :SETVAR DB_NAME_TEXT "EXPECT INSERT OF DB_NAME_ASSIGN HERE: "

    /*Get output*/

    SELECT '$(DB_NAME_TEXT)' + '$(DB_NAME_ASSIGN)' AS OUTPUT

    /* Delivers:

    EXPECT INSERT OF DB_NAME_ASSIGN HERE: TEST TEXT

    */

    how can I make the opposite this possible? That is, to declare variables in T_SQL and pass them to SQLCMD mode and execute them? For example, consider the following:

    declare

    @src_db_name sysname,

    @target_db_name sysname,

    @src_web_svr_name varchar(75),

    @target_web_svr_name varchar(75),

    @SQLCMDLine varchar(250)

    SELECT@src_db_name = 'DEVELDB',

    @target_db_name = 'TESTDB',

    @src_web_svr_name = 'DEVELSERVER',

    @target_web_svr_name = 'TESTSERVER'

    SELECT @SQLCMDLine = 'xcopy \\' + @src_web_svr_name + '\Apps\FTPServer\FSCM90\' + @src_db_name + '\*.* '

    SELECT @SQLCMDLine = @SQLCMDLine + ' \\' + @target_web_svr_name + '\Apps\FTPServer\FSCM90\' + @target_db_name + '\*.* '

    /* This is where I can't it to work */

    !! sqlcmd @SQLCMDLine

    Anybody ever dealt with this one?

    what's the error you are getting? For your statement, I wouldn't use SELECT, I would use SET. Does your server have robocopy? that will make your life easier. any of the following robocopy syntax will do the trick.

    robocopy source\folder destination\folder *.* /E

    robocopy source\folder destination\folder /E

    robocopy source\folder destination\folder /MIR

    why is robocopy better than xcopy? robocopy has retries, will resume where it failed, able to ID old and new files.

    -----------------------------
    www.cbtr.net
    .: SQL Backup Admin Tool[/url] :.