-- Get object_id from object name
select OBJECT_ID('[dbo].[testobject]')
-- get object_name from object id
select OBJECT_NAME(213575799)
Linux
Posts about Linux operating system
SQL Server – Display Running Tasks
Use this query in conjunction with sp_who to display running tasks and determine whether there are sessions blocking other sessions, and who is executing the query (sp_who)
SELECT command,
r.session_id, r.blocking_session_id,
s.text,
start_time,
percent_complete,
CAST(((DATEDIFF(s,start_time,GetDate()))/3600) as varchar) + ' hour(s), '
+ CAST((DATEDIFF(s,start_time,GetDate())%3600)/60 as varchar) + 'min, '
+ CAST((DATEDIFF(s,start_time,GetDate())%60) as varchar) + ' sec' as running_time,
CAST((estimated_completion_time/3600000) as varchar) + ' hour(s), '
+ CAST((estimated_completion_time %3600000)/60000 as varchar) + 'min, '
+ CAST((estimated_completion_time %60000)/1000 as varchar) + ' sec' as est_time_to_go,
dateadd(second,estimated_completion_time/1000, getdate()) as est_completion_time
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) s
--WHERE r.command like ('%DBCC%')
Changing SQL Server Database Collation
free -m
Real Memory Consumption = Total – (free + buffers + cached)
# free -m
total used free shared buffers cached
Mem: 15943 15678 265 6 511 3706
-/+ buffers/cache: 11460 4483
Swap: 8159 0 8159
# cat /proc/meminfo|grep -i huge
AnonHugePages: 0 kB
HugePages_Total: 4916
HugePages_Free: 3413
HugePages_Rsvd: 35
HugePages_Surp: 0
Hugepagesize: 2048 kB
The total memory reserved for huge pages is approximately 10 G ((4916 * 2048) /1024/1024)
This is approximately equal to 'used' on the second line of the 'free -m' command 11460/1024 = 11G
On an Oracle database server, the Huge Pages should be about 70-80% of the physical RAM - varies with size, not a hard rule.
On an Oracle database server, the ulimits for the oracle user should be set accordingly - this means that the Oracle user
hard and soft limits for memory should be set high enough
Following files are modified to enable Huge Pages and disable transparent huge pages
/etc/grub.conf
kernel …… transparent_hugepage=never
--> reboot
Example:
8G RAM --> set 70% for Huge Pages = 5.6G --> set vm.nr_hugepages=2688 in /etc/sysctl.conf --> 5.55G HugePages
--> 2 databases with SGA_TARGET set to 2.6G or 1 database with SGA_TARGET set to 5.5G
MEMORY_TARGET set to 0 (AMM should be disabled when Huge Pages are configured)
/etc/sysctl.conf
vm.nr_hugepages=2688
(a number representing the number of pages – no unit)
Multiply by 2048 (K) and divide by 1024*1024 to get the number of GB of memory --> 5.55 G in this case
vm.hugetlb_shm_group=3000
/etc/security/limits.conf
e.g set 7G = 7*1024*1024 = 7340032 --> for a server with 8G of memory
Another example for memlock ulimits:
Set the value (in KB) slightly smaller than installed RAM. e.g. If you have 64GB RAM installed, you may set
soft memlock 60397977
hard memlock 60397977
(works out to 57G)
Flush and Reset Client Resolver Cache
ipconfig /flushdns
Powershell Environment Variables
$env
$env:path
$env:PSModulePath
Full list
Get-Childitem env:
Snipping Tool – Capture Contextual Menu
When you want to capture a menu option, (that annoyingly disappears when you try to capture with snipping tool), use the following
procedure:
- Ensure there is no current capture in the snipping tool program (open/reopen snipping tool)
- To capture a screen clip of a contextual menu, press ctrl-print-screen
Help about regular expressions in powershell
To get help about regular expressions in powershell, at the command prompt:
help about_regular_expression
List Server Principals (Logins/Users) – SQL Server
use[master] -- SQL Server authentication logins select * from sys.sql_logins -- all logins/users select * from sys.server_principals order by type_desc
Display Job Information – SQL Server
use [msdb] select * from sysjobs select * from sysjobactivity select * from sysjobs_view select * from sysjobhistory order by job_id, step_id