using System.Data.SqlClient; // create a connection SqlConnection connection = new SqlConnection("Data Source=datasource;Initial Catalog=dbname;User ID=username;Password=password"); // open the connection connection.Open(); // create a SqlBulkCopy object SqlBulkCopy bulkCopy = new SqlBulkCopy(connection); // set the destination table bulkCopy.DestinationTableName = "dbo.MyTable"; // load data into DataTable or SqlDataReader // write data to SQL Server database bulkCopy.WriteToServer(data); // close the SqlBulkCopy object bulkCopy.Close(); // close the connection connection.Close();In this example, we create a connection to a SQL Server database and open it. We then create a SqlBulkCopy object and set the destination table. Next, we load data into a DataTable or SqlDataReader and write it to the SQL Server database using the WriteToServer method. Finally, we call the Close method to close the SqlBulkCopy object and release any resources associated with it. This code uses the System.Data.SqlClient package library.