database-management etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
database-management etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

13 Ekim 2019 Pazar

How to get ram and cpu information from within SQL Server?

xp_instance_regread -> It is an undocumented stored proc for reading registry settings. 


If the following script is run, it returns cpu mark, model information.


EXEC xp_instance_regread
'HKEY_LOCAL_MACHINE',
'HARDWARE\DESCRIPTION\System\CentralProcessor\0',
'ProcessorNameString';


sys.dm_os_sys_info -> The other method to collect cpu information is sys.dm_os_sys_info system view. It contains logical cpu count,physical cpu count, total memory etc..


I prepared a script that how to get cpu some cpu information within Sql Server.


--- How to get cpu-ram  


drop table if exists #tmp1 ---may run on sqlserver 2016 and later

create table #tmp1(id int default(1),Val varchar(100),
[Data] varchar(100))


insert into #tmp1(Val,[Data])
EXEC xp_instance_regread
'HKEY_LOCAL_MACHINE',
'HARDWARE\DESCRIPTION\System\CentralProcessor\0',
'ProcessorNameString';


select compname as ComputerName, 
       Data    as ProcessorName,
  Number_of_Logical_CPU,
  hyperthread_ratio,
  Number_of_Physical_CPU,
  Total_Physical_Memory_IN_KB
from (
select 1 as id,
SERVERPROPERTY('MachineName')  as compname ) as tbl
inner join #tmp1 on tbl.id=#tmp1.id
inner join (
SELECT 1 as id,
cpu_count AS [Number_of_Logical_CPU]
,hyperthread_ratio
,cpu_count/hyperthread_ratio AS [Number_of_Physical_CPU]
,physical_memory_kb/1024 AS [Total_Physical_Memory_IN_KB]
FROM sys.dm_os_sys_info
) as tbl2 on tbl.id=tbl2.id OPTION (RECOMPILE);




9 Ekim 2019 Çarşamba

How to listen SqlServer on multiple ports?





We can connect SQL Server on multiple ports. How can we do this step-by-step? 1- Open SQL Server Configuration Manager. 2- Click to expand SQL Server Network Configuration 3- Select your instance 4- On the right side, right click on TCP/IP then select properties.
























5- In the tcp/ip window, select ip addresses tab 6- At the bottom of the window there is a IPAll part
































7- In the TCP Port field, enter each port number separated by commas. Then click OK. 8- A pop up message will be appear. Click ok.




You must restart Sql Server Service. Stop and start Sql Server Service or restart. After the restarting, SQL Server will be listening on all the port numbers you specified. 9-If you would like to verify changes you can look at the Sql Server Logs. If it is successful you should see below messages in Sql Server Logs: Server is listening on [ ‘any’ <ipv4> 5555]. Server is listening on [ ‘any’ <ipv6> 5555]. Server is listening on [ ‘any’ <ipv4> 6666]. Server is listening on [ ‘any’ <ipv6> 6666]. Server is listening on [ ‘any’ <ipv4> 7777]. Server is listening on [ ‘any’ <ipv6> 7777]. 10-The other way to control connection is creating a UDL file. Create a udl file. Check the connection by entering the IP number and port. 





                                                      














Temporary Stored Procedures in Sql Server

Temporary stored procedures are similar to temporary tables. It creates in the tempdb. There are 2 kinds of temp procs: temporary stored pro...