Skip to main content

A Qualified Doctor can save you with limited medicines!

Dear Readers          Hope you all are doing well!          This is in continuation to the post  https://pamwritings.blogspot.com/2026/08/medical-capital-of-india.html .                  Five years ago, due to many reasons, I started feeling irritation while urinating. unfortunately, it intensified further and I immediately visited a local doctor who is supposed to be an experienced doctor with MD qualification. Later on, one medical shop revealed the truth that he is not an allopathic professional and still prescribing allopathic medicines.          He told me to take the tablet he prescribed for the first 2 days, can continue if required. This is the first time I listen to an advice like this and was doubtful. After taking the tablet for 2 days, infection further worsened and I started almost bleeding, a reddish color I could see. My friend near my hom...

Loading 50 million records in 50 minutes in SQL Server - Super fast data loading

 Greetings to all the readers!!

 Yes, it is possible to load 1 million of records in 1 minute time from one SQL server to another.


 Create an SSIS package with a Script task.

  •  Add logging for ease of debugging and make all the connections configurable to make it re-usable.
  •  In the script task, we have to use .net script given below. We can define the batch size and   timeout.
  •  By Default, Identity in the destination is reset, in case you have to preserve it, amend the code      accordingly.

In my task, I used SQL Server 2017, SSIS 2017 and the source system is SQL 2008 R2

 C#

using System.Data.SqlClient;


class Program

{

    static void Main()

    {

        string connectionString = GetConnectionString();

        // Open a sourceConnection to the AdventureWorks database.

        using (SqlConnection sourceConnection =

                   new SqlConnection(connectionString))

        {

            sourceConnection.Open();


            // Perform an initial count on the destination table.

            SqlCommand commandRowCount = new SqlCommand(

                "SELECT COUNT(*) FROM " +

                "dbo.BulkCopyDemoMatchingColumns;",

                sourceConnection);

            long countStart = System.Convert.ToInt32(

                commandRowCount.ExecuteScalar());

            Console.WriteLine("Starting row count = {0}", countStart);


            // Get data from the source table as a SqlDataReader.

            SqlCommand commandSourceData = new SqlCommand(

                "SELECT ProductID, Name, " +

                "ProductNumber " +

                "FROM Production.Product;", sourceConnection);

            SqlDataReader reader =

                commandSourceData.ExecuteReader();


            // Open the destination connection. In the real world you would

            // not use SqlBulkCopy to move data from one table to the other

            // in the same database. This is for demonstration purposes only.

            using (SqlConnection destinationConnection =

                       new SqlConnection(connectionString))

            {

                destinationConnection.Open();


                // Set up the bulk copy object.

                // Note that the column positions in the source

                // data reader match the column positions in

                // the destination table so there is no need to

                // map columns.

                using (SqlBulkCopy bulkCopy =

                           new SqlBulkCopy(destinationConnection))

                {

                    bulkCopy.DestinationTableName =

                        "dbo.BulkCopyDemoMatchingColumns";


                    try

                    {

                        // Write from the source to the destination.

                        bulkCopy.WriteToServer(reader);

                    }

                    catch (Exception ex)

                    {

                        Console.WriteLine(ex.Message);

                    }

                    finally

                    {

                        // Close the SqlDataReader. The SqlBulkCopy

                        // object is automatically closed at the end

                        // of the using block.

                        reader.Close();

                    }

                }


                // Perform a final count on the destination

                // table to see how many rows were added.

                long countEnd = System.Convert.ToInt32(

                    commandRowCount.ExecuteScalar());

                Console.WriteLine("Ending row count = {0}", countEnd);

                Console.WriteLine("{0} rows were added.", countEnd - countStart);

                Console.WriteLine("Press Enter to finish.");

                Console.ReadLine();

            }

        }

    }


    private static string GetConnectionString()

        // To avoid storing the sourceConnection string in your code,

        // you can retrieve it from a configuration file.

    {

        return "Data Source=(local); " +

            " Integrated Security=true;" +

            "Initial Catalog=AdventureWorks;";

    }

}


Reference

SqlBulkCopy Class (System.Data.SqlClient) | Microsoft Learn

Comments

Popular posts from this blog

What makes Life 100 percent

Dear Readers Just a story from my own experience In our life, there are many qualities we have such as patience, talent, knowledge, etc. Though we have all these, do you know which one makes your life 100 percent.  Let’s find it using a mathematical calculation. Firstly, Knowledge –   Sum up the place value of each character.                                         –       11 + 14 + 15 + 23 + 12 + 5 + 4 + 7 + 5 = 96 Then, Health – 8 + 5 + 1 + 12 + 20 + 8 = 54 Money – 13 + 15 + 14 + 5 + 25 = 72. Peace – 16 + 5 + 1 + 3 + 4 = 24 Oh, No. none of these 100%. All of our favorite things have gone. What else does it. Let’s try a new one, Attitude – 1 + 20 + 20 + 9 + 20 + 21 + 4 + 5 = 100, wow. Finally, we got it. It is our Attitude make the life 100%. Always have a positive, healthy, and good attitude. That’s more than enough....

A True Inspiration for me

 Dear Readers          Today I am going to write about my college friend and how he has become an inspiration to me.                                  Let's go for a flash back, in the year 2006 I had to join Diploma in Electrical and Electronics Engineering as I did not have sufficient financial background to join Bachelor of Engineering.          There I met so many good people in my life. One of them is Kiruba, my close friend till date.           He was a normal student, average scoring in academics and known for his good conduct. The day I came to know about his family responsibilities I was shocked. Some of us might have seen in movies, one guy who has more sisters has to work day and night to discharge his family duties.          He has one elder sister and two younger sisters. He nev...

Additional Discount on VU TV

Dear Readers Hope you all are doing well One of the leading smart TV brands in india VU is offering additional discounts across all it’s models. This is an online only brand, we can’t get this brand from retail outlets like Reliance digital, Croma, etc. If we buy it from online portals like flipkart, amazon, etc we get around 30% discount on MRP. When I was trying to purchase this model, I happened to see an online article which showed the own website of VU, that offered me additional 2000 rupees. So please make use of this opportunity to avail maximum discounts on VU TV. Vu Televisions - Official Website (vutvs.com)