Wednesday, January 26, 2022

.::: Query index fragmentation level SQL Server with detail, specify Table, Database :::.


1. index fragmentation level

SELECT @@servername as Server, DB_NAME(ips.database_id) AS DatabaseName,
       SCHEMA_NAME(ob.[schema_id]) SchemaNames,
       ob.[name] AS ObjectName,
       ix.[name] AS IndexName,
       ob.type_desc AS ObjectType,
       ix.type_desc AS IndexType,
       -- ips.partition_number AS PartitionNumber,
       ips.page_count AS [PageCount], -- Only Available in DETAILED Mode
       ips.record_count AS [RecordCount],
       ips.avg_fragmentation_in_percent AS AvgFragmentationInPercent
-- FROM sys.dm_db_index_physical_stats (NULL, NULL, NULL, NULL, 'DETAILED') ips
FROM sys.dm_db_index_physical_stats (NULL, NULL, NULL, NULL, 'SAMPLED') ips -- QuickResult
INNER JOIN sys.indexes ix ON ips.[object_id] = ix.[object_id]
                AND ips.index_id = ix.index_id
INNER JOIN sys.objects ob ON ix.[object_id] = ob.[object_id]
WHERE ob.[type] IN('U','V')
AND ob.is_ms_shipped = 0
AND ix.[type] IN(1,2,3,4)
AND ix.is_disabled = 0
AND ix.is_hypothetical = 0
AND ips.alloc_unit_type_desc = 'IN_ROW_DATA'
AND ips.index_level = 0
-- AND ips.page_count >= 1000 -- Filter to check only table with over 1000 pages
-- AND ips.record_count >= 100 -- Filter to check only table with over 1000 rows
-- AND ips.database_id = DB_ID() -- Filter to check only current database
-- AND ips.avg_fragmentation_in_percent > 50 -- Filter to check over 50% indexes
-- ORDER BY DatabaseName
order by ips.avg_fragmentation_in_percent desc, DatabaseName asc

Tuesday, January 18, 2022

.::: Query Check ServerName, Database Name, Database ID, Table ID, Object ID,Object Name, Size Table, master_files, size Database :::.


1. Info ServerName, Version, db_name

select @@SERVERNAME as ServerName,
       @@SERVICENAME as ServiceName,
       db_name() as DBName,
       @@VERSION as VersionDB,
       @@MICROSOFTVERSION as MICROSOFTVERSION,
       @@LANGUAGE as Language
 

Friday, January 14, 2022

.::: Create Store Procedure & Check Dependencies :::.


A. Sample Query 1 & Store Procedure 1
1. Sample 1
-- Query 1
select b.NAMA_BARANG,s.NAMA_SUPLIER,p.TANGGAL_PASOK,p.JUMLAH_PASOK from barang b,suplier s,pasok p where b.KODE_BARANG=p.KODE_BARANG and s.KODE_SUPLIER=p.KODE_SUPLIER;


2. Store Procedure 1

Create Procedure Barang_pasok

as
 begin
 select b.NAMA_BARANG,s.NAMA_SUPLIER,p.TANGGAL_PASOK,p.JUMLAH_PASOK from   barang b,suplier s,pasok p where b.KODE_BARANG=p.KODE_BARANG and  s.KODE_SUPLIER=p.KODE_SUPLIER;

end

Thursday, January 13, 2022

.::: Insert Into table from Linkedserver to Linkedserver with Open Query & dbname(database_id) :::.

A. Linked Server (MSSQL)

1. Check Database ID on Linked Server
select @@Servername as LocalServer,@@servername as ServerName_Link, name as dbname,database_id  from sys.databases


2. Check Result Query on Linked Server
SELECT @@Servername as LocalServer, @@Servername as ServerName_Link,db_name('5')  as [DBName], * from teguhth.dbo.barang

Monday, December 27, 2021

.::: Create Report SQL Server Using SSRS (Sample Lab ) :::.


A. Check Table SQL Server
select * from barang;

B. Install & Enable SSRS Service


.::: Performance Compare 4 CPU vs 1 CPU In SQL Server Using Execution Plan (Setting MaxDop Max Degree Of Parallelism) :::.

 
1. Download & restore AdventureWorks2019
2. Open New Query and run Query below & Execute

set Statistics io, time on
use AdventureWorks2019

-- Query running on 4 logical processors

Tuesday, December 21, 2021

.::: Lab Integration SSIS with SQL Server using SQL Jobs Agent :::.



A. Create Database & Table from Source & Destination
1. Create database source
tgh_source

2. create table source
create table barang(
KODE_BARANG char(6) not null ,
NAMA_BARANG varchar(25), 
SATUAN_BARANG varchar(20),
STOK_BARANG decimal(4),
primary key (KODE_BARANG));

.::: Configure Enable NTP Server & Client Windows Server using Group Policy Editor :::.

 A. Windows Server become NTP Server
1. Open Group Policy Editor (gpedit.msc)

2. Open Time Provider
Computer Configuration > Administrative Templates > System > Windows Time Service > Time Providers.

.::: Cannot Remote Desktop Connection : An Authentication error has Occured. Due to CredSSP Encryption Oracle Remedian :::.

 

1. Open Registry

2. Open Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters

3. Double-click the AllowEncryptionOracle DWORD to open its Edit DWORD window.

Enter the value ‘2‘ in the Value data text box, and press the OK button.

Friday, December 10, 2021

Wednesday, November 24, 2021

.::: Install Database Oracle 19C in Linux Centos 7 :::.


 .::: Install Database Oracle 19C in Linux Centos 7 :::.

1. Disable firewalld
[root@teguhth ~]# systemctl stop firewalld
[root@teguhth ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@teguhth ~]# 


2. add /etc/hosts
[root@teguhth ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.10.10.50 teguhth
[root@teguhth ~]# 

Friday, October 22, 2021

.::: Latihan SSIS convert csv file to SQL / MSSQL :::.



1. Create database on SQL Server 
create database LatSSIS;
use LatSSIS;
go

.::: Configure log shipping SQL Server :::.

 to monitor log shipping

http://teguhth.blogspot.com/2023/09/monitor-transaction-log-shipping-using.html

1. Enable Log Shipping on Database 1


Popular Posts