i copy scripts from msdn then run at sqlserver 2008 r2 with sp3 ,report error

  • i copy scripts from msdn https://technet.microsoft.com/en-us/library/ms181929(v=sql.105).aspx

    then run at sqlserver 2008 r2 with sp3 ,report error

    SELECT TOP 5

    total_worker_time / execution_count AS [Avg CPU Time] ,

    SUBSTRING(st.text, ( qs.statement_start_offset / 2 ) + 1,

    ( ( CASE qs.statement_end_offset

    WHEN -1 THEN DATALENGTH(st.text)

    ELSE qs.statement_end_offset

    END - qs.statement_start_offset ) / 2 ) + 1) AS statement_text

    FROM sys.dm_exec_query_stats AS qs

    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st --message 102,lever 15,statss 1,row 9 '.' near with error

    ORDER BY total_worker_time / execution_count DESC;

    what should i do ?

  • Have you Googled the error message?


    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    —Charles Babbage, Passages from the Life of a Philosopher

    How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537

  • Using copy/paste from your post, I tried the query on my database (which is SQL Server 2012, so not the same version) and it ran without error.

    Can you repost the complete error message using copy/paste from the error window? (I see some typos in the error message so I assume you typed it here instead of using copy/paste).

    When you double-click the error message, what line in the query window is highlighted?


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply