Monday, April 25, 2022

.::: Simulation Execution Plan SQl Server & how to read :::.


1. query 1
USE [teguhth]
GO

Create Procedure [dbo].[SpBarang_pasok]

as
begin

select @@SERVERNAME as ServerName,
       @@servicename as ServiceName,
       DB_NAME() AS DBName,
       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
order by TANGGAL_PASOK

end
GO

 

Thursday, April 21, 2022

.::: Object ID, ObJect Name, Physical Index, database size, index size, drive size in MSSQL SQL Server :::.

274100017 = Person
2101582525 = EmployeeDepartmentHistory

1. List Object ID, Object Name, Table Name
SELECT  @@servername as ServerName,
        db_name() as [DBName],
        name as TableName,
        object_id,
        OBJECT_ID(name) AS [OBJECT_ID(name)]
FROM sys.objects
-- where  name = 'barang' or name = 'customer' or name = 'suplier' or
-- name = 'pasok' or name = 'pembelian' or name = 'sysdiagrams'
where  name in ('barang','customer','suplier','pasok','pembelian','sysdiagrams')
order by object_id

Tuesday, April 19, 2022

.::: How to list all objects of a particular database in SQL Server (List Object Name, Object ID) :::.

   SELECT @@servername as ServerName,db_name() as DbName, o.type_desc AS Object_Type
       ,  s.name AS Schema_Name
       ,  o.name AS Object_Name,object_id
       ,  o.name AS ObjectName
    FROM  sys.objects o
    JOIN  sys.schemas s
      ON  s.schema_id = o.schema_id
   WHERE  o.type NOT IN ('S'  --SYSTEM_TABLE
                        ,'PK' --PRIMARY_KEY_CONSTRAINT
                        ,'D'  --DEFAULT_CONSTRAINT
                        ,'C'  --CHECK_CONSTRAINT
                        ,'F'  --FOREIGN_KEY_CONSTRAINT
                        ,'IT' --INTERNAL_TABLE
                        ,'SQ' --SERVICE_QUEUE
                        ,'TR' --SQL_TRIGGER
                        ,'UQ' --UNIQUE_CONSTRAINT
                        )
ORDER BY  Object_Type
       ,  SCHEMA_NAME
       ,  Object_Name


 

Popular Posts