Search

sys.dm_exec_sql_text bug by Joe.TJ

Resolved
as By Design Help for as By Design

1
0
Sign in
to vote
Type: Bug
ID: 776561
Opened: 1/14/2013 11:17:36 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
在非master上下文中,使用sys.dm_exec_sql_text,一直报错:Incorrect syntax near '.'.
是否这个表值函数只能在master中使用。
我的SQL Server版本号:Microsoft SQL Server 2008 (SP2) - 10.0.4000.0 (X64) Sep 16 2010 19:43:16 Copyright (c) 1988-2008 Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
Details (expand)

Product Language

English

Version

SQL Server 2008 SP2

Category

SQL Engine

Operating System

Windows Server 2008 R2 Standard

Operating System Language

US English

Steps to Reproduce

use no_master
go
select es.session_id,es.host_name,es.login_name,st.text,GETDATE() as dt
from sys.dm_exec_sessions es
inner join sys.dm_exec_requests er
on es.session_id=er.session_id
cross apply master.sys.dm_exec_sql_text(er.sql_handle) st
where es.session_id=@@SPID

Actual Results

应该列出我查询的列,却报语法错误

Expected Results

应该列出我查询的列,却报语法错误

Platform

 

Virtualization

 
File Attachments
0 attachments
Sign in to post a comment.
Posted by Joe.TJ on 1/16/2013 at 7:27 PM
的确是兼容级别的问题。谢谢
Posted by Microsoft on 1/15/2013 at 11:48 AM
Hello,
The behavior you are seeing is by design. The APPLY operator is available only if your current database has compatibility level >= 90. So please make sure you run the query from a database that matches the compatibility level.

--
Umachandar, SQL Programmability Team
Sign in to post a workaround.