Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1042065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:26:55+00:00 2026-05-16T15:26:55+00:00

I do not have ‘full’ the version of MS SQL (SQL Express 2008) so

  • 0

I do not have ‘full’ the version of MS SQL (SQL Express 2008) so I do not have the profiler tool.

I want to see the SQL generated by my Entity Framework code, but all of the examples I find use the

var x = from u in table
        select u;

type of syntax; But most of my queries are more like ..

var x = context.Users.Single(n => n.Name == "Steven");

type of syntax. What can I do to see the SQL generated, from this manner of coding? Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:26:55+00:00Added an answer on May 16, 2026 at 3:26 pm

    Does Express Edition support extended events? If so this will capture statement and sp completed events in a similar way to Profiler.

    Edit: I have changed it to use a memory target rather than a file target. Ideally uncomment the WHERE sections and replace with an appropriate user name to capture only events of interest or you can filter by spid with WHERE (([sqlserver].[session_id]=(56))) for example.

    IF EXISTS(SELECT * FROM sys.server_event_sessions WHERE name='test_trace')
        DROP EVENT SESSION [test_trace] ON SERVER;
    CREATE EVENT SESSION [test_trace]
    ON SERVER
    ADD EVENT sqlserver.sp_statement_completed(
         ACTION (package0.callstack, sqlserver.session_id, sqlserver.sql_text)
        -- WHERE (([sqlserver].[username]='Domain\Username'))
        ),
    ADD EVENT sqlserver.sql_statement_completed(
         ACTION (package0.callstack, sqlserver.session_id, sqlserver.sql_text)
         --WHERE (([sqlserver].[username]='Domain\Username'))
         )
    ADD TARGET package0.ring_buffer
    WITH (MAX_MEMORY = 4096KB, EVENT_RETENTION_MODE = ALLOW_SINGLE_EVENT_LOSS, 
    MAX_DISPATCH_LATENCY = 1 SECONDS, MAX_EVENT_SIZE = 0KB, 
    MEMORY_PARTITION_MODE = NONE, TRACK_CAUSALITY = OFF, STARTUP_STATE = OFF)
    
    ALTER EVENT SESSION [test_trace] ON SERVER STATE = START
    

    And to review the results (Query generated using Adam Machanic’s XE Code Generator)

    DECLARE 
        @session_name VARCHAR(200) = 'test_trace'
    
    SELECT 
        pivoted_data.* 
    FROM 
    ( 
     SELECT MIN(event_name) AS event_name,
         MIN(event_timestamp) AS event_timestamp,
         unique_event_id,
         CONVERT ( BIGINT, MIN (
             CASE
                 WHEN d_name = 'cpu'
                 AND d_package IS NULL
                 THEN d_value
             END ) ) AS [cpu],
         CONVERT ( BIGINT, MIN (
             CASE
                 WHEN d_name = 'duration'
                 AND d_package IS NULL
                 THEN d_value
             END ) ) AS [duration],
         CONVERT ( BIGINT, MIN (
             CASE
                 WHEN d_name = 'object_id'
                 AND d_package IS NULL
                 THEN d_value
             END ) ) AS [object_id],
         CONVERT ( INT, MIN (
             CASE
                 WHEN d_name = 'object_type'
                 AND d_package IS NULL
                 THEN d_value
             END ) ) AS [object_type],
         CONVERT ( DECIMAL(28,0), MIN (
             CASE
                 WHEN d_name = 'reads'
                 AND d_package IS NULL
                 THEN d_value
             END ) ) AS [reads],
         CONVERT ( VARCHAR(MAX), MIN (
             CASE
                 WHEN d_name = 'session_id'
                 AND d_package IS NOT NULL
                 THEN d_value
             END ) ) AS [session_id],
         CONVERT ( INT, MIN (
             CASE
                 WHEN d_name = 'source_database_id'
                 AND d_package IS NULL
                 THEN d_value
             END ) ) AS [source_database_id],
         CAST((SELECT CONVERT ( VARCHAR(MAX), MIN (
             CASE
                 WHEN d_name = 'sql_text'
                 AND d_package IS NOT NULL
                 THEN d_value
             END ) )  AS [processing-instruction(x)] FOR XML PATH('') ) AS XML) AS [sql_text],
         CONVERT ( DECIMAL(28,0), MIN (
             CASE
                 WHEN d_name = 'writes'
                 AND d_package IS NULL
                 THEN d_value
             END ) ) AS [writes]
     FROM
        ( 
            SELECT 
                *, 
                CONVERT(VARCHAR(400), NULL) AS attach_activity_id 
            FROM 
            ( 
                SELECT 
                    event.value('(@name)[1]', 'VARCHAR(400)') as event_name, 
                    event.value('(@timestamp)[1]', 'DATETIME') as event_timestamp, 
                    DENSE_RANK() OVER (ORDER BY event) AS unique_event_id, 
                    n.value('(@name)[1]', 'VARCHAR(400)') AS d_name, 
                    n.value('(@package)[1]', 'VARCHAR(400)') AS d_package, 
                    n.value('((value)[1]/text())[1]', 'VARCHAR(MAX)') AS d_value, 
                    n.value('((text)[1]/text())[1]', 'VARCHAR(MAX)') AS d_text 
                FROM 
                ( 
                    SELECT 
                        ( 
                            SELECT 
                                CONVERT(xml, target_data) 
                            FROM sys.dm_xe_session_targets st 
                            JOIN sys.dm_xe_sessions s ON 
                                s.address = st.event_session_address 
                            WHERE 
                                s.name = @session_name 
                                AND st.target_name = 'ring_buffer' 
                        ) AS [x] 
                    FOR XML PATH(''), TYPE 
                ) AS the_xml(x) 
                CROSS APPLY x.nodes('//event') e (event) 
                CROSS APPLY event.nodes('*') AS q (n) 
            ) AS data_data 
        ) AS activity_data 
        GROUP BY 
            unique_event_id 
    ) AS pivoted_data; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Heroku does not have built-in SQL console, so I have used the third party
Does VC++ 2010 Express not have std::thread? I am using the multi-threaded DLL. The
I have nested arrays that do not have keys. I want to add keys
Did not have luck with these examples: Javascript File remove Javascript FSO DeleteFile Method
I have a Xaml file that does not have any code behind. I would
I have a website that does not have page refreshes when the visitor navigates
I have a class which does not have copy constructor or operator= overloaded. The
I do NOT have config.active_record.whitelist_attributes = true in application config. And I have attr_protected()
Why does .Net not have the System.Float type like System.String , System.Double etc.?
I have an unweighted directed graph that may or may not have cycles in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.