I have XML Data which i have converted as Datatable then i used SQL Bulk Copy method to Insert into SQL Database. - It is Working as Expected.
But as i am working with Batch Job - If already existing record comes in it should update not Insert again I tried with Userdefined table but it is not much clear as XML Data and SQL Table Column are totally different
so could you any one advice
          DataTable dt = ds.Tables[0];
          if (dt.Rows.Count > 0)
          {
              using (SqlConnection con = new SqlConnection(consString))
              {
                  using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(con))
                  {
                      using (SqlCommand cmd = new SqlCommand("[dbo].[usp_usgcap_stgjns]"))
                      {
                          cmd.CommandType = CommandType.StoredProcedure;
                          cmd.Connection = con;
                          //Set the database table name
                          sqlBulkCopy.DestinationTableName = "[dbo].[usgcap_stgjns]";
                          //[OPTIONAL]: Map the DataTable columns with that of the database table
 
                          sqlBulkCopy.ColumnMappings.Add("CustomerId", "company_Id");
                           
 
                          con.Open();
                          //sqlBulkCopy.WriteToServer(dt);
 
                          cmd.ExecuteNonQuery();
                           
                          con.Close();
                      }
                  }