Reputation: 28980
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 ))
Upvotes: 0
Views: 337
Reputation: 114751
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.
Upvotes: 2