我是C#的新手,所以请耐心等待,因为我继承了一个我试图调整的脚本.
我想让SQL PRINT/RAISERROR语句的输出显示在已在脚本的另一部分中声明的日志文件中.
这是我打电话的方法:
public void ProcessData(string StoredProcedure, int StartDate, int EndDate, string Directory, string LogFileNameAndPath)
{
SqlConnection sqlConnection = null;
SqlCommand sqlCommand = null;
SqlParameter sqlParameter = null;
// String outputText = null;
try
{
sqlConnection = new SqlConnection(_ConnectionString);
sqlConnection.Open();
sqlCommand = new SqlCommand();
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = StoredProcedure;
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandTimeout = 0;
sqlParameter = new SqlParameter("@StartDt", SqlDbType.Int);
sqlParameter.Value = StartDate;
sqlCommand.Parameters.Add(sqlParameter);
sqlParameter = new SqlParameter("@EndDt", SqlDbType.Int);
sqlParameter.Value = EndDate;
sqlCommand.Parameters.Add(sqlParameter);
sqlParameter = new SqlParameter("@stringDirs", SqlDbType.VarChar); …Run Code Online (Sandbox Code Playgroud) 我正在尝试以增量方式引入索赔数据。我在System( varchar) 和ClaimNum( varchar)上匹配源和目标,并使用其他列的散列来检查更改。
我有我的合并语句(简化):
MERGE target
USING source ON target.System = source.System
AND target.ClaimNum = source.ClaimNum
WHEN MATCHED AND target.HashValue <> source.HashValue
THEN {update claim record data}
WHEN MATCHED AND target.HashValue = source.HashValue
THEN {update claim record as "checked"}
WHEN NOT MATCHED
THEN {insert new claim record}
Run Code Online (Sandbox Code Playgroud)
但是,我不能有 2 个匹配的条件。我还可以如何使用合并语句完成此操作?
这用于 SQL Server 2008。