Buenas Tardes .
Tengo un pequeño problemilla, en mi antiguo trabajo se diseño un pequeño
monitor de procesos de la base de datos, pero ahi se trabajaba con Sybase
12.5 , ahora quiero implementar dicho monitoreo pero para un servidor de
SqlServer pero cuando lo compilo tengo errores en las tablas del sistema, si
alguien pudiera ayudar en la equivalenciade dichos campos del SYBASE en el
SQL Server.
el store es el sgte
drop proc sp_genwho
go
create proc sp_genwho ( @parametro int )
as
if @parametro = 0
BEGIN
select
ID_Ps = convert(varchar(3),master..sysprocesses.spid),
No_Pr = convert(varchar(3),master..sysprocesses.enginenum),
Comando = convert(varchar(30),master..sysprocesses.cmd),
Cpu = master..sysprocesses.cpu,
IO = master..sysprocesses.physical_io,
Objeto = object_name(master..sysprocesses.id),
Linea = master..sysprocesses.linenum,
Estado = master..sysprocesses.status,
Bqd = convert(varchar(5),master..sysprocesses.blocked),
Tim_Bqd = master..sysprocesses.time_blocked ,
Transac = convert(varchar(30),master..sysprocesses.tran_name),
Login = convert(varchar(12),suser_name(master..sysprocesses.suid)),
Nom_PC = convert(varchar(12),master..sysprocesses.hostname),
Usr_NT = convert(varchar(12),master..sysprocesses.clientname),
SisGen = convert(varchar(12),master..sysprocesses.clienthostname),
PgmSisGen = CASE WHEN master..sysprocesses.clientapplname = "" THEN '(SYB) '
+ convert(varchar(30),master..sysprocesses.program_name) ELSE '(PGM) ' +
convert(varchar(30),master..sysprocesses.clientapplname) END,
BaseDato = convert(varchar(12),db_name(master..sysprocesses.dbid)),
IdObjeto=master..sysprocesses.id
from master..sysprocesses
order by master..sysprocesses.fid, master..sysprocesses.spid
END
if @parametro = 1
BEGIN
select
ID_Ps = convert(varchar(3),master..sysprocesses.spid),
No_Pr = convert(varchar(3),master..sysprocesses.enginenum),
Comando = convert(varchar(30),master..sysprocesses.cmd),
Cpu = master..sysprocesses.cpu,
IO = master..sysprocesses.physical_io,
Objeto = object_name(master..sysprocesses.id),
Linea = master..sysprocesses.linenum,
Estado = master..sysprocesses.status,
Bqd = convert(varchar(5),master..sysprocesses.blocked),
Tim_Bqd = master..sysprocesses.time_blocked ,
Transac = convert(varchar(30),master..sysprocesses.tran_name),
Login = convert(varchar(12),suser_name(master..sysprocesses.suid)),
Nom_PC = convert(varchar(12),master..sysprocesses.hostname),
Usr_NT = convert(varchar(12),master..sysprocesses.clientname),
SisGen = convert(varchar(12),master..sysprocesses.clienthostname),
PgmSisGen = CASE WHEN master..sysprocesses.clientapplname = "" THEN '(SYB) '
+ convert(varchar(30),master..sysprocesses.program_name) ELSE '(PGM) ' +
convert(varchar(30),master..sysprocesses.clientapplname) END,
BaseDato = convert(varchar(12),db_name(master..sysprocesses.dbid)),
IdObjeto=master..sysprocesses.id
from master..sysprocesses
where cmd <> "AWAITING COMMAND"
order by master..sysprocesses.fid, master..sysprocesses.spid
END
if @parametro = 2
BEGIN
select
ID_Ps = convert(varchar(3),master..sysprocesses.spid),
No_Pr = convert(varchar(3),master..sysprocesses.enginenum),
Comando = convert(varchar(30),master..sysprocesses.cmd),
Cpu = master..sysprocesses.cpu,
IO = master..sysprocesses.physical_io,
Objeto = object_name(master..sysprocesses.id),
Linea = master..sysprocesses.linenum,
Estado = master..sysprocesses.status,
Bqd = convert(varchar(5),master..sysprocesses.blocked),
Tim_Bqd = master..sysprocesses.time_blocked ,
Transac = convert(varchar(30),master..sysprocesses.tran_name),
Login = convert(varchar(12),suser_name(master..sysprocesses.suid)),
Nom_PC = convert(varchar(12),master..sysprocesses.hostname),
Usr_NT = convert(varchar(12),master..sysprocesses.clientname),
SisGen = convert(varchar(12),master..sysprocesses.clienthostname),
PgmSisGen = CASE WHEN master..sysprocesses.clientapplname = "" THEN '(SYB) '
+ convert(varchar(30),master..sysprocesses.program_name) ELSE '(PGM) ' +
convert(varchar(30),master..sysprocesses.clientapplname) END,
BaseDato = convert(varchar(12),db_name(master..sysprocesses.dbid)),
IdObjeto=master..sysprocesses.id
from master..sysprocesses
where cmd <> "AWAITING COMMAND" and master..sysprocesses.suid > 0
order by master..sysprocesses.fid, master..sysprocesses.spid
END
Gracias de antemano a cualquier ayuda que reciba.
Manuel Aparcana Reyes
Analisista Programador
(511) 9503-4295
Leer las respuestas