sybase查看用户正在运行的sql语句
2011-11-22 13:59
302 查看
以sa登陆
>dbcc traceon(3604)
>go
>dbcc sqltext(sp_id)
>go
能看到连接sp_id的运行的sql语句
sp__id可由sp_who查出,这样如果数据库出现lock的时候可以查询是什么sql原因造成的
写成存储过程更简单!我已经用很久了,呵呵
if exists (select 1 from sysobjects where (sysstat & 7) = 4 and name = 'sp_sql')
begin
drop procedure sp_sql
end
go
print "Installing sp_sql"
go
create procedure sp_sql
@spid smallint
as
declare
@retvalue int
begin
if @@trancount = 0
begin
set chained off
end
set transaction isolation level 1
set flushmessage on
set nocount on
if (@spid > 0)
begin
dbcc traceon(3604)
print "==============================================================================="
dbcc sqltext(@spid)
print "==============================================================================="
dbcc traceoff(3604)
select @retvalue = @@error
end
else
begin
select @retvalue = -200
end
return @retvalue
end
go
exec sp_procxmode 'sp_sql', 'anymode'
go
grant execute on sp_sql to public
go
>dbcc traceon(3604)
>go
>dbcc sqltext(sp_id)
>go
能看到连接sp_id的运行的sql语句
sp__id可由sp_who查出,这样如果数据库出现lock的时候可以查询是什么sql原因造成的
写成存储过程更简单!我已经用很久了,呵呵
if exists (select 1 from sysobjects where (sysstat & 7) = 4 and name = 'sp_sql')
begin
drop procedure sp_sql
end
go
print "Installing sp_sql"
go
create procedure sp_sql
@spid smallint
as
declare
@retvalue int
begin
if @@trancount = 0
begin
set chained off
end
set transaction isolation level 1
set flushmessage on
set nocount on
if (@spid > 0)
begin
dbcc traceon(3604)
print "==============================================================================="
dbcc sqltext(@spid)
print "==============================================================================="
dbcc traceoff(3604)
select @retvalue = @@error
end
else
begin
select @retvalue = -200
end
return @retvalue
end
go
exec sp_procxmode 'sp_sql', 'anymode'
go
grant execute on sp_sql to public
go
相关文章推荐
- sybase查看用户正在运行的sql语句
- 如何查看数据库中某用户,正在运行什么SQL 语句
- 查看当前正在运行的SQL语句的统计信息
- oracle如何查看后台正在运行着的sql语句
- 使用v$sql_monitor视图查看当前正在运行的SQL语句的统计信息
- oracle如何查看后台正在运行着的sql语句
- 查询oracle中正在运行的sql语句,不包括plsql执行的查询语句
- 查看当前oracle中正在执行的sql语句
- 查看oracle用户执行的sql语句历史记录
- Oracle查看用户默认表空间使用情以及手动扩展表空间sql语句
- 查看最近用户使用过的sql语句
- 查看当前oracle中正在执行的sql语句
- 使用 SQL Server Management Studio的活动和监视器 查看运行的SQL语句
- oracle之 v$sql_monitor 监视正在运行的SQL语句的统计信息
- 查看mysql正在执行的SQL语句,使用profile分析SQL执行状态
- 如何查看,当运行一个hibernate 方法后到底执行了哪些SQL语句
- 查看当前运行的SQL语句
- 通过日志查看MySQL正在执行的SQL语句
- 查看mysql正在执行的SQL语句
- 查看oracle 用户执行的sql语句历史记录