SQL comments not preserved when viewing in Azure query detailsInserting multiple rows in a single SQL query?SQL update query using joinsHow do I view the SQL generated by the Entity Framework?How to resolve Azure “Windows logins are not supported in this version of SQL Server”?Entity Framework query slow, but same SQL in SqlQuery is fastEntity framework can't connect to new table but only when deployed to Azure?How to connect to Azure SQL database?Entity Framework naming queriesRunning SQL Queries against Azure SQL with the replacement for Transient Fault Handling without using EFHow to accommodate Azure SQL query that runs infrequently but is very resource intensive

Cross-referencing enumerate item

Can't stopover at Sapporo when going from Asahikawa to Chitose airport?

How would one country purchase another?

Why does The Ancient One think differently about Doctor Strange in Endgame than the film Doctor Strange?

Why isn't "I've" a proper response?

If all stars rotate, why was there a theory developed, that requires non-rotating stars?

Are there account age or level requirements for obtaining special research?

Did a flight controller ever answer Flight with a no-go?

How should I face my manager if I make a mistake because a senior coworker explained something incorrectly to me?

Average period of peer review process

Architectural feasibility of a tiered circular stone keep

Are there any music source codes for sound chips?

Why different interest rates for checking and savings?

What is the hex versus octal timeline?

Why were the crew so desperate to catch Truman and return him to Seahaven?

How to respectfully refuse to assist co-workers with IT issues?

Is "The life is beautiful" incorrect or just very non-idiomatic?

Are modern clipless shoes and pedals that much better than toe clips and straps?

LeetCode: Pascal's Triangle C#

Rule based coloured background for labeling in QGIS

Are there any elected officials in the U.S. who are not legislators, judges, or constitutional officers?

Most practical knots for hitching a line to an object while keeping the bitter end as tight as possible, without sag?

Can you feel passing through the sound barrier in an F-16?

I have a player who yells



SQL comments not preserved when viewing in Azure query details


Inserting multiple rows in a single SQL query?SQL update query using joinsHow do I view the SQL generated by the Entity Framework?How to resolve Azure “Windows logins are not supported in this version of SQL Server”?Entity Framework query slow, but same SQL in SqlQuery is fastEntity framework can't connect to new table but only when deployed to Azure?How to connect to Azure SQL database?Entity Framework naming queriesRunning SQL Queries against Azure SQL with the replacement for Transient Fault Handling without using EFHow to accommodate Azure SQL query that runs infrequently but is very resource intensive






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















We're using .NET Entity Framework to talk to an Azure SQL database. We used QueryOriginInterceptor to add some comments to the top of each SQL command being sent to SQL Server, with the goal of helping identify the location where a particular query came from in the code.



The problem is, when looking at long running queries in the Azure UI (and looking in sys.dm_exec_query_stats), the comments are not there.



For example, if we run this query:



-- Stack:
-- Utils.Orders.GetOrders
select *
from [Order] o
join OrderItem oi on oi.OrderId = o.ID


And looking in Azure, the long running query looks like:



enter image description here



Is there a way to preserve these comments?










share|improve this question



















  • 1





    Why do you think comments will show up? The Azure connection is html and html comments do not get processed.

    – jdweng
    Mar 27 at 16:34











  • @jdweng: A SQL comment is not a HTML comment -- is not a comment marking for HTML. Also, not being processed is not the same as not being parsed. My browser ignored all comments in the webpage's html but it still shows the comments when I inspect the HTML.

    – Flater
    Mar 28 at 14:43












  • See following : docs.microsoft.com/en-us/azure/active-directory-b2c/…

    – jdweng
    Mar 28 at 15:52

















2















We're using .NET Entity Framework to talk to an Azure SQL database. We used QueryOriginInterceptor to add some comments to the top of each SQL command being sent to SQL Server, with the goal of helping identify the location where a particular query came from in the code.



The problem is, when looking at long running queries in the Azure UI (and looking in sys.dm_exec_query_stats), the comments are not there.



For example, if we run this query:



-- Stack:
-- Utils.Orders.GetOrders
select *
from [Order] o
join OrderItem oi on oi.OrderId = o.ID


And looking in Azure, the long running query looks like:



enter image description here



Is there a way to preserve these comments?










share|improve this question



















  • 1





    Why do you think comments will show up? The Azure connection is html and html comments do not get processed.

    – jdweng
    Mar 27 at 16:34











  • @jdweng: A SQL comment is not a HTML comment -- is not a comment marking for HTML. Also, not being processed is not the same as not being parsed. My browser ignored all comments in the webpage's html but it still shows the comments when I inspect the HTML.

    – Flater
    Mar 28 at 14:43












  • See following : docs.microsoft.com/en-us/azure/active-directory-b2c/…

    – jdweng
    Mar 28 at 15:52













2












2








2








We're using .NET Entity Framework to talk to an Azure SQL database. We used QueryOriginInterceptor to add some comments to the top of each SQL command being sent to SQL Server, with the goal of helping identify the location where a particular query came from in the code.



The problem is, when looking at long running queries in the Azure UI (and looking in sys.dm_exec_query_stats), the comments are not there.



For example, if we run this query:



-- Stack:
-- Utils.Orders.GetOrders
select *
from [Order] o
join OrderItem oi on oi.OrderId = o.ID


And looking in Azure, the long running query looks like:



enter image description here



Is there a way to preserve these comments?










share|improve this question














We're using .NET Entity Framework to talk to an Azure SQL database. We used QueryOriginInterceptor to add some comments to the top of each SQL command being sent to SQL Server, with the goal of helping identify the location where a particular query came from in the code.



The problem is, when looking at long running queries in the Azure UI (and looking in sys.dm_exec_query_stats), the comments are not there.



For example, if we run this query:



-- Stack:
-- Utils.Orders.GetOrders
select *
from [Order] o
join OrderItem oi on oi.OrderId = o.ID


And looking in Azure, the long running query looks like:



enter image description here



Is there a way to preserve these comments?







c# sql-server entity-framework azure






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 16:28









LavamantisLavamantis

2,4081 gold badge18 silver badges19 bronze badges




2,4081 gold badge18 silver badges19 bronze badges










  • 1





    Why do you think comments will show up? The Azure connection is html and html comments do not get processed.

    – jdweng
    Mar 27 at 16:34











  • @jdweng: A SQL comment is not a HTML comment -- is not a comment marking for HTML. Also, not being processed is not the same as not being parsed. My browser ignored all comments in the webpage's html but it still shows the comments when I inspect the HTML.

    – Flater
    Mar 28 at 14:43












  • See following : docs.microsoft.com/en-us/azure/active-directory-b2c/…

    – jdweng
    Mar 28 at 15:52












  • 1





    Why do you think comments will show up? The Azure connection is html and html comments do not get processed.

    – jdweng
    Mar 27 at 16:34











  • @jdweng: A SQL comment is not a HTML comment -- is not a comment marking for HTML. Also, not being processed is not the same as not being parsed. My browser ignored all comments in the webpage's html but it still shows the comments when I inspect the HTML.

    – Flater
    Mar 28 at 14:43












  • See following : docs.microsoft.com/en-us/azure/active-directory-b2c/…

    – jdweng
    Mar 28 at 15:52







1




1





Why do you think comments will show up? The Azure connection is html and html comments do not get processed.

– jdweng
Mar 27 at 16:34





Why do you think comments will show up? The Azure connection is html and html comments do not get processed.

– jdweng
Mar 27 at 16:34













@jdweng: A SQL comment is not a HTML comment -- is not a comment marking for HTML. Also, not being processed is not the same as not being parsed. My browser ignored all comments in the webpage's html but it still shows the comments when I inspect the HTML.

– Flater
Mar 28 at 14:43






@jdweng: A SQL comment is not a HTML comment -- is not a comment marking for HTML. Also, not being processed is not the same as not being parsed. My browser ignored all comments in the webpage's html but it still shows the comments when I inspect the HTML.

– Flater
Mar 28 at 14:43














See following : docs.microsoft.com/en-us/azure/active-directory-b2c/…

– jdweng
Mar 28 at 15:52





See following : docs.microsoft.com/en-us/azure/active-directory-b2c/…

– jdweng
Mar 28 at 15:52












1 Answer
1






active

oldest

votes


















0















sys.dm_exec_query_stats does not include the comments, but dm_exec_sql_text does.



This artice explains how to use the two to diagnose issues.



The relevant SQL query from the article is:



SELECT TOP 25
databases.name,
dm_exec_sql_text.text AS TSQL_Text,
CAST(CAST(dm_exec_query_stats.total_worker_time AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as cpu_per_execution,
CAST(CAST(dm_exec_query_stats.total_logical_reads AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as logical_reads_per_execution,
CAST(CAST(dm_exec_query_stats.total_elapsed_time AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as elapsed_time_per_execution,
dm_exec_query_stats.creation_time,
dm_exec_query_stats.execution_count,
dm_exec_query_stats.total_worker_time AS total_cpu_time,
dm_exec_query_stats.max_worker_time AS max_cpu_time,
dm_exec_query_stats.total_elapsed_time,
dm_exec_query_stats.max_elapsed_time,
dm_exec_query_stats.total_logical_reads,
dm_exec_query_stats.max_logical_reads,
dm_exec_query_stats.total_physical_reads,
dm_exec_query_stats.max_physical_reads,
dm_exec_query_plan.query_plan,
dm_exec_cached_plans.cacheobjtype,
dm_exec_cached_plans.objtype,
dm_exec_cached_plans.size_in_bytes
FROM sys.dm_exec_query_stats
CROSS APPLY sys.dm_exec_sql_text(dm_exec_query_stats.plan_handle)
CROSS APPLY sys.dm_exec_query_plan(dm_exec_query_stats.plan_handle)
INNER JOIN sys.databases
ON dm_exec_sql_text.dbid = databases.database_id
INNER JOIN sys.dm_exec_cached_plans
ON dm_exec_cached_plans.plan_handle = dm_exec_query_stats.plan_handle
WHERE databases.name = 'AdventureWorks2014'
ORDER BY dm_exec_query_stats.max_logical_reads DESC;





share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55382144%2fsql-comments-not-preserved-when-viewing-in-azure-query-details%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0















    sys.dm_exec_query_stats does not include the comments, but dm_exec_sql_text does.



    This artice explains how to use the two to diagnose issues.



    The relevant SQL query from the article is:



    SELECT TOP 25
    databases.name,
    dm_exec_sql_text.text AS TSQL_Text,
    CAST(CAST(dm_exec_query_stats.total_worker_time AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as cpu_per_execution,
    CAST(CAST(dm_exec_query_stats.total_logical_reads AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as logical_reads_per_execution,
    CAST(CAST(dm_exec_query_stats.total_elapsed_time AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as elapsed_time_per_execution,
    dm_exec_query_stats.creation_time,
    dm_exec_query_stats.execution_count,
    dm_exec_query_stats.total_worker_time AS total_cpu_time,
    dm_exec_query_stats.max_worker_time AS max_cpu_time,
    dm_exec_query_stats.total_elapsed_time,
    dm_exec_query_stats.max_elapsed_time,
    dm_exec_query_stats.total_logical_reads,
    dm_exec_query_stats.max_logical_reads,
    dm_exec_query_stats.total_physical_reads,
    dm_exec_query_stats.max_physical_reads,
    dm_exec_query_plan.query_plan,
    dm_exec_cached_plans.cacheobjtype,
    dm_exec_cached_plans.objtype,
    dm_exec_cached_plans.size_in_bytes
    FROM sys.dm_exec_query_stats
    CROSS APPLY sys.dm_exec_sql_text(dm_exec_query_stats.plan_handle)
    CROSS APPLY sys.dm_exec_query_plan(dm_exec_query_stats.plan_handle)
    INNER JOIN sys.databases
    ON dm_exec_sql_text.dbid = databases.database_id
    INNER JOIN sys.dm_exec_cached_plans
    ON dm_exec_cached_plans.plan_handle = dm_exec_query_stats.plan_handle
    WHERE databases.name = 'AdventureWorks2014'
    ORDER BY dm_exec_query_stats.max_logical_reads DESC;





    share|improve this answer





























      0















      sys.dm_exec_query_stats does not include the comments, but dm_exec_sql_text does.



      This artice explains how to use the two to diagnose issues.



      The relevant SQL query from the article is:



      SELECT TOP 25
      databases.name,
      dm_exec_sql_text.text AS TSQL_Text,
      CAST(CAST(dm_exec_query_stats.total_worker_time AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as cpu_per_execution,
      CAST(CAST(dm_exec_query_stats.total_logical_reads AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as logical_reads_per_execution,
      CAST(CAST(dm_exec_query_stats.total_elapsed_time AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as elapsed_time_per_execution,
      dm_exec_query_stats.creation_time,
      dm_exec_query_stats.execution_count,
      dm_exec_query_stats.total_worker_time AS total_cpu_time,
      dm_exec_query_stats.max_worker_time AS max_cpu_time,
      dm_exec_query_stats.total_elapsed_time,
      dm_exec_query_stats.max_elapsed_time,
      dm_exec_query_stats.total_logical_reads,
      dm_exec_query_stats.max_logical_reads,
      dm_exec_query_stats.total_physical_reads,
      dm_exec_query_stats.max_physical_reads,
      dm_exec_query_plan.query_plan,
      dm_exec_cached_plans.cacheobjtype,
      dm_exec_cached_plans.objtype,
      dm_exec_cached_plans.size_in_bytes
      FROM sys.dm_exec_query_stats
      CROSS APPLY sys.dm_exec_sql_text(dm_exec_query_stats.plan_handle)
      CROSS APPLY sys.dm_exec_query_plan(dm_exec_query_stats.plan_handle)
      INNER JOIN sys.databases
      ON dm_exec_sql_text.dbid = databases.database_id
      INNER JOIN sys.dm_exec_cached_plans
      ON dm_exec_cached_plans.plan_handle = dm_exec_query_stats.plan_handle
      WHERE databases.name = 'AdventureWorks2014'
      ORDER BY dm_exec_query_stats.max_logical_reads DESC;





      share|improve this answer



























        0














        0










        0









        sys.dm_exec_query_stats does not include the comments, but dm_exec_sql_text does.



        This artice explains how to use the two to diagnose issues.



        The relevant SQL query from the article is:



        SELECT TOP 25
        databases.name,
        dm_exec_sql_text.text AS TSQL_Text,
        CAST(CAST(dm_exec_query_stats.total_worker_time AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as cpu_per_execution,
        CAST(CAST(dm_exec_query_stats.total_logical_reads AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as logical_reads_per_execution,
        CAST(CAST(dm_exec_query_stats.total_elapsed_time AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as elapsed_time_per_execution,
        dm_exec_query_stats.creation_time,
        dm_exec_query_stats.execution_count,
        dm_exec_query_stats.total_worker_time AS total_cpu_time,
        dm_exec_query_stats.max_worker_time AS max_cpu_time,
        dm_exec_query_stats.total_elapsed_time,
        dm_exec_query_stats.max_elapsed_time,
        dm_exec_query_stats.total_logical_reads,
        dm_exec_query_stats.max_logical_reads,
        dm_exec_query_stats.total_physical_reads,
        dm_exec_query_stats.max_physical_reads,
        dm_exec_query_plan.query_plan,
        dm_exec_cached_plans.cacheobjtype,
        dm_exec_cached_plans.objtype,
        dm_exec_cached_plans.size_in_bytes
        FROM sys.dm_exec_query_stats
        CROSS APPLY sys.dm_exec_sql_text(dm_exec_query_stats.plan_handle)
        CROSS APPLY sys.dm_exec_query_plan(dm_exec_query_stats.plan_handle)
        INNER JOIN sys.databases
        ON dm_exec_sql_text.dbid = databases.database_id
        INNER JOIN sys.dm_exec_cached_plans
        ON dm_exec_cached_plans.plan_handle = dm_exec_query_stats.plan_handle
        WHERE databases.name = 'AdventureWorks2014'
        ORDER BY dm_exec_query_stats.max_logical_reads DESC;





        share|improve this answer













        sys.dm_exec_query_stats does not include the comments, but dm_exec_sql_text does.



        This artice explains how to use the two to diagnose issues.



        The relevant SQL query from the article is:



        SELECT TOP 25
        databases.name,
        dm_exec_sql_text.text AS TSQL_Text,
        CAST(CAST(dm_exec_query_stats.total_worker_time AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as cpu_per_execution,
        CAST(CAST(dm_exec_query_stats.total_logical_reads AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as logical_reads_per_execution,
        CAST(CAST(dm_exec_query_stats.total_elapsed_time AS DECIMAL)/CAST(dm_exec_query_stats.execution_count AS DECIMAL) AS INT) as elapsed_time_per_execution,
        dm_exec_query_stats.creation_time,
        dm_exec_query_stats.execution_count,
        dm_exec_query_stats.total_worker_time AS total_cpu_time,
        dm_exec_query_stats.max_worker_time AS max_cpu_time,
        dm_exec_query_stats.total_elapsed_time,
        dm_exec_query_stats.max_elapsed_time,
        dm_exec_query_stats.total_logical_reads,
        dm_exec_query_stats.max_logical_reads,
        dm_exec_query_stats.total_physical_reads,
        dm_exec_query_stats.max_physical_reads,
        dm_exec_query_plan.query_plan,
        dm_exec_cached_plans.cacheobjtype,
        dm_exec_cached_plans.objtype,
        dm_exec_cached_plans.size_in_bytes
        FROM sys.dm_exec_query_stats
        CROSS APPLY sys.dm_exec_sql_text(dm_exec_query_stats.plan_handle)
        CROSS APPLY sys.dm_exec_query_plan(dm_exec_query_stats.plan_handle)
        INNER JOIN sys.databases
        ON dm_exec_sql_text.dbid = databases.database_id
        INNER JOIN sys.dm_exec_cached_plans
        ON dm_exec_cached_plans.plan_handle = dm_exec_query_stats.plan_handle
        WHERE databases.name = 'AdventureWorks2014'
        ORDER BY dm_exec_query_stats.max_logical_reads DESC;






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 28 at 13:53









        SamaraSoucy-MSFTSamaraSoucy-MSFT

        1,0371 gold badge1 silver badge12 bronze badges




        1,0371 gold badge1 silver badge12 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55382144%2fsql-comments-not-preserved-when-viewing-in-azure-query-details%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현