可以通过以下步骤实现:
以下是一个示例代码:
using System;
using System.Data;
using System.Data.SqlClient;
using Oracle.ManagedDataAccess.Client;
class Program
{
static void Main()
{
string oracleConnectionString = "Data Source=OracleServer;User Id=username;Password=password;";
string sqlServerConnectionString = "Data Source=SqlServer;Initial Catalog=database;User Id=username;Password=password;";
using (OracleConnection oracleConnection = new OracleConnection(oracleConnectionString))
{
oracleConnection.Open();
string oracleQuery = "SELECT high_precision_float_column FROM oracle_table";
using (OracleCommand oracleCommand = new OracleCommand(oracleQuery, oracleConnection))
{
using (OracleDataReader oracleDataReader = oracleCommand.ExecuteReader())
{
DataTable dataTable = new DataTable();
dataTable.Load(oracleDataReader);
using (SqlConnection sqlConnection = new SqlConnection(sqlServerConnectionString))
{
sqlConnection.Open();
using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(sqlConnection))
{
sqlBulkCopy.DestinationTableName = "sql_server_table";
sqlBulkCopy.ColumnMappings.Add("high_precision_float_column", "high_precision_float_column");
sqlBulkCopy.WriteToServer(dataTable);
}
}
}
}
}
Console.WriteLine("Data transfer completed.");
}
}
在上述示例代码中,需要将"OracleServer"替换为实际的Oracle数据库服务器名称,"username"和"password"替换为实际的Oracle数据库的用户名和密码,"SqlServer"替换为实际的SQL Server数据库服务器名称,"database"替换为实际的SQL Server数据库名称,"username"和"password"替换为实际的SQL Server数据库的用户名和密码。
此外,需要确保在.Net项目中引用了Oracle.ManagedDataAccess和System.Data.SqlClient这两个程序集。
对于高精度浮点数的传输,可以使用Oracle的NUMBER数据类型和SQL Server的DECIMAL或NUMERIC数据类型。
推荐的腾讯云相关产品:腾讯云数据库SQL Server版(https://cloud.tencent.com/product/tcsqlserver)
领取专属 10元无门槛券
手把手带您无忧上云