For a long time to run .SQL Script in AZURE using sql server management studio and c # coding

I am having a problem creating a database and running a .SQL Script file in Azure using C #. When I test it manually on my Local machine and local machine instance it only takes 15 seconds , but when I run this same Script file in Azure it takes 6 coins and 37 seconds . I have no idea why it is taking such a long time. Could you help me...

Create Script as shown below using SQL Server Management Studio (version: 11.0.9230)

  • Database Script Engine Type: Azure SQL Database

  • Data Types for Script: Schema and Data

  • Script Triggers: Truth

    Total size of Script file: 6553 KB.

Running the same Script file through encoding takes almost 12 mints and 48 seconds. C # code:

Regex regex = new Regex("^GO", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                        string SQLAllText = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "SQLEXPRESS\\Emptyscript.sql");
                        string[] SqlLine = regex.Split(SQLAllText);
                        foreach (string Line in SqlLine)
                        {
                            try
                            {
                                Errormessage = Line;
                                SqlCmd.CommandText = Line;
                                SqlCmd.ExecuteNonQuery();
                            }
                            catch (Exception ex)
                            {

                                MessageBox.Show(Errormessage);
                                objLog.Write(ex, "NewCompanyDatabaseWCF", "CreateDatabase");
                            }
                        }

      

Could you please advise me how I can quickly run a Script file very quickly in Azure

thank

Victor.A

+3


source to share


1 answer


The script execution speed depends on the performance level your database is in and how many resources your queries are requesting. You can query the "sys.resource_Stats" view to see the resource usage of the script. If you want this script to execute quickly and once and then grow your database, execute the script and zoom out. You can also use other dmvs like dm_exec_Requests, dm_db_Wait_stats to see bottlenecks.



+2


source







All Articles