我正在c#app中创建一个批处理文件,以便从Windows任务计划程序在SQL Server中运行存储过程。
StreamWriter sw = new StreamWriter(batchFileName);
sw.WriteLine("SQLCMD -s " + serverName + " -d " +
databaseName +
"-Q dbo.ua.sp_PostPeriodicDues @periodCode=$(param1) @nextPostDate=$(param2) @repost=$(param3) @localFieldName=$(param4) @userCd=$(param5) @returnValue=$(param6)" +
"-v param1=" + periodCode + " param2=" + nextPostingDate + " param3=" + repost + " param4=" +
localFieldName + " param5=" + userCd + " param6=" + returnValue);
sw.Flush();
sw.Close();
这是调用SQLCMD并传递参数的正确方法吗?