Tuesday, March 27, 2012
Can I get Total CPU usage or Memory use by TSQL
I dont have direct access to Server Terminal.
Can I get Server CPU Utilization and total memory use and memory use
by sql server using TSQL?
Regards
Amish Shah
Hi
It is not clear what you are looking for hear. You may want to look at the
set options:
SET SET STATISTICS IO ON
SET SET STATISTICS TIME ON
or look at SQL Profiler.
John
"amish" wrote:
> Hi
> I dont have direct access to Server Terminal.
> Can I get Server CPU Utilization and total memory use and memory use
> by sql server using TSQL?
> Regards
> Amish Shah
>
|||Actually I want to know total cpu utilization and memory utilization of
server and how much sql server consuming in this both. I can connect to
the server only by sql server. I dont have windows user/password.
So, is there any way i can get this information by tsql?
Thanks
AM
*** Sent via Developersdex http://www.codecomments.com ***
|||Hi
You may want to look at @.@.CPU_BUSY, @.@.IDLE, @.@.TIMETICKS or sp_monitor
You may also want to check out DBCC RESOURCE at
http://www.transactsql.com/html/DBCC%20RESOURCE.html
and other dbcc commands such as DBCC PERFMON, DBCC PROCCACHE, DBCC BUFFER
although I am not sure where to find total memory used.
Also look at sp_configure to find out the maximum configured value.
John
"AM" wrote:
> Actually I want to know total cpu utilization and memory utilization of
> server and how much sql server consuming in this both. I can connect to
> the server only by sql server. I dont have windows user/password.
> So, is there any way i can get this information by tsql?
> Thanks
> AM
> *** Sent via Developersdex http://www.codecomments.com ***
>
|||Some times CPU Utilization of my server goes upto 80% to 100 %. I want
to get this detail using TSQL.
I also want to know how much % sql server taking of over all cpu
utilization.
I want to do all this using SQL Server.
Thanks
AM
*** Sent via Developersdex http://www.codecomments.com ***
|||Hi
This is really the job of performance monitor, and this will give you a
pro-active method of monitoring it. I suggest you get the system admin to set
these up. If you are using MOM or similar you can do it that way.
John
"AM" wrote:
> Some times CPU Utilization of my server goes upto 80% to 100 %. I want
> to get this detail using TSQL.
> I also want to know how much % sql server taking of over all cpu
> utilization.
> I want to do all this using SQL Server.
>
> Thanks
> AM
> *** Sent via Developersdex http://www.codecomments.com ***
>
Can I get Total CPU usage or Memory use by TSQL
I dont have direct access to Server Terminal.
Can I get Server CPU Utilization and total memory use and memory use
by sql server using TSQL?
Regards
Amish ShahHi
It is not clear what you are looking for hear. You may want to look at the
set options:
SET SET STATISTICS IO ON
SET SET STATISTICS TIME ON
or look at SQL Profiler.
John
"amish" wrote:
> Hi
> I dont have direct access to Server Terminal.
> Can I get Server CPU Utilization and total memory use and memory use
> by sql server using TSQL?
> Regards
> Amish Shah
>|||Hi
You may want to look at @.@.CPU_BUSY, @.@.IDLE, @.@.TIMETICKS or sp_monitor
You may also want to check out DBCC RESOURCE at
http://www.transactsql.com/html/DBCC%20RESOURCE.html
and other dbcc commands such as DBCC PERFMON, DBCC PROCCACHE, DBCC BUFFER
although I am not sure where to find total memory used.
Also look at sp_configure to find out the maximum configured value.
John
"AM" wrote:
> Actually I want to know total cpu utilization and memory utilization of
> server and how much sql server consuming in this both. I can connect to
> the server only by sql server. I dont have windows user/password.
> So, is there any way i can get this information by tsql?
> Thanks
> AM
> *** Sent via Developersdex http://www.developersdex.com ***
>|||Hi
This is really the job of performance monitor, and this will give you a
pro-active method of monitoring it. I suggest you get the system admin to set
these up. If you are using MOM or similar you can do it that way.
John
"AM" wrote:
> Some times CPU Utilization of my server goes upto 80% to 100 %. I want
> to get this detail using TSQL.
> I also want to know how much % sql server taking of over all cpu
> utilization.
> I want to do all this using SQL Server.
>
> Thanks
> AM
> *** Sent via Developersdex http://www.developersdex.com ***
>
Can I get Total CPU usage or Memory use by TSQL
I dont have direct access to Server Terminal.
Can I get Server CPU Utilization and total memory use and memory use
by sql server using TSQL?
Regards
Amish ShahHi
It is not clear what you are looking for hear. You may want to look at the
set options:
SET SET STATISTICS IO ON
SET SET STATISTICS TIME ON
or look at SQL Profiler.
John
"amish" wrote:
> Hi
> I dont have direct access to Server Terminal.
> Can I get Server CPU Utilization and total memory use and memory use
> by sql server using TSQL?
> Regards
> Amish Shah
>|||Actually I want to know total cpu utilization and memory utilization of
server and how much sql server consuming in this both. I can connect to
the server only by sql server. I dont have windows user/password.
So, is there any way i can get this information by tsql?
Thanks
AM
*** Sent via Developersdex http://www.codecomments.com ***|||Hi
You may want to look at @.@.CPU_BUSY, @.@.IDLE, @.@.TIMETICKS or sp_monitor
You may also want to check out DBCC RESOURCE at
http://www.transactsql.com/html/DBCC%20RESOURCE.html
and other dbcc commands such as DBCC PERFMON, DBCC PROCCACHE, DBCC BUFFER
although I am not sure where to find total memory used.
Also look at sp_configure to find out the maximum configured value.
John
"AM" wrote:
> Actually I want to know total cpu utilization and memory utilization of
> server and how much sql server consuming in this both. I can connect to
> the server only by sql server. I dont have windows user/password.
> So, is there any way i can get this information by tsql?
> Thanks
> AM
> *** Sent via Developersdex http://www.codecomments.com ***
>|||Some times CPU Utilization of my server goes upto 80% to 100 %. I want
to get this detail using TSQL.
I also want to know how much % sql server taking of over all cpu
utilization.
I want to do all this using SQL Server.
Thanks
AM
*** Sent via Developersdex http://www.codecomments.com ***|||Hi
This is really the job of performance monitor, and this will give you a
pro-active method of monitoring it. I suggest you get the system admin to se
t
these up. If you are using MOM or similar you can do it that way.
John
"AM" wrote:
> Some times CPU Utilization of my server goes upto 80% to 100 %. I want
> to get this detail using TSQL.
> I also want to know how much % sql server taking of over all cpu
> utilization.
> I want to do all this using SQL Server.
>
> Thanks
> AM
> *** Sent via Developersdex http://www.codecomments.com ***
>sql
Sunday, March 25, 2012
Can I do Regular Expressions using TSQL in SQL Server2005?
CREATE FUNCTION
dbo.fn_regex(@.pattern varchar(255), @.matchstring varchar(8000))
RETURNS int
AS
BEGIN
declare @.obj int
declare @.res int
declare @.match bit
set @.match=0
exec @.res=sp_OACreate 'VBScript.RegExp',@.obj OUT
IF (@.res <> 0) BEGIN
RETURN NULL
END
exec @.res=sp_OASetProperty @.obj, 'Pattern', @.pattern
IF (@.res <> 0) BEGIN
RETURN NULL
END
exec @.res=sp_OASetProperty @.obj, 'IgnoreCase', 1
IF (@.res <> 0) BEGIN
RETURN NULL
END
exec @.res=sp_OAMethod @.obj, 'Test',@.match OUT, @.matchstring
IF (@.res <> 0) BEGIN
RETURN NULL
END
exec @.res=sp_OADestroy @.obj
return @.match
END
GO
When you say the functiuon doesn't work in SQL 2005; in what way doesn't it work? I see that you are using sp_OAxxx and friends; you are aware that you need to explicitly enable sp_OAxxx in S2K5, as a server setting?Also, youwould be much, much, much better off using the CLR integration to do your stuff than sp_OA
Niels
|||Thanks for your response nielsb. Do you know if I can use CLR integration in a TSQL function. I am using PHP with SQL Server, so I do not have the option to use VB.net or C#?
Thanks!|||I don't fully understand the question? But, you can have s function written in C#, VB.NET, that's doing your stuff, and that function can be called by some T-SQL functions.
Niels
|||I cannot write the function in VB.NET or C#, as I am using PHP with SQL Server 2005 (which leave me the only option of write a TSQL function)|||Hmm, I still don't understand why you can not write a VB.NET or C# function. I.e. SQL Server 2005 hosts the CLR. You write a CLR function doing your regex stuff, this function is hosted by SQL Server and exposed by a T-SQL function. Your PHP code then calls the T-SQL function. Or am I totally off-track here?
Niels
|||Thanks for the response Niels! Do you think I can write a C# or VB.NET CLR function and call it within TSQL? Could you maybe give me an example of a CLR function. I have not used this before. your response is very much appreciated!