简体   繁体   中英

TFS SqlExecute Custom Activity

I use SqlExecute activity of Build Extension

I wish pass params in arguments of my activity

But my problem is Te parameters are not injected into the SQL script, can you help me please. have you used SqlExecute activity?

Parameters Section in editor, in my build designer of template tfs / wwf :

New String(5) {
    "BackupFilePath = F:\MSSQL10.IS_CLTLIVE_DE\DUMP\ClearProdDump\CP.dmp",
    "LogicalDataFile = CP_Data01",
    "DataFilePath = F:\MSSQL10.IS_CLTLIVE_DE\data\",
    "LogicalLogFile = CP_TLog01",
    "LogFilePath = F:\MSSQL10.IS_CLTLIVE_DE\log\",
    "DatabaseName = AghilasCP_Tmp"
}

My Script.sql

IF  EXISTS (SELECT name FROM sys.databases WHERE name = $(DatabaseName ))

Reading the code of that activity it seems that you need to specify the parameters as

New String(5) {
    "@BackupFilePath='F:\MSSQL10.IS_CLTLIVE_DE\DUMP\ClearProdDump\CP.dmp'",
    "@LogicalDataFile='CP_Data01'",
    "@DataFilePath='F:\MSSQL10.IS_CLTLIVE_DE\data\'",
    "@LogicalLogFile='CP_TLog01'",
    "@LogFilePath='F:\MSSQL10.IS_CLTLIVE_DE\log\'",
    "@DatabaseName='AghilasCP_Tmp'"
}

And the statement as

IF  EXISTS (SELECT name FROM sys.databases WHERE name = @DatabaseName)

With no spaces around the '=', with a unique name as a parameter name, this scares me a bit, I'd personally have written built this activity differently, and with quotes around the parameter value either in the parameter array or in the SQL code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM