This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TRIGGER <schema>.<table_name>_read_only_events ON <schema>.<table_name> | |
INSTEAD OF INSERT, | |
UPDATE, | |
DELETE | |
AS | |
BEGIN | |
RAISERROR( 'table is read only.', 16, 1 ) | |
ROLLBACK TRANSACTION | |
END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;WITH CTE_Dev | |
AS ( | |
SELECT C.column_id | |
,ColumnName = C.NAME | |
,C.max_length | |
,C.user_type_id | |
,C.precision | |
,C.scale | |
,DataTypeName = T.NAME | |
FROM sys.columns C |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install library | |
pip install pywin32 | |
# import komponen | |
import win32com.client | |
# untuk membuka excel | |
xl = win32com.client.Dispatch('Excel.Application') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyodbc | |
import time | |
from shutil import copy | |
import smtplib | |
import os | |
import datetime | |
def backup_db(cnxn,mode,backup_dir,secondary_backup_dirs,dbname): | |
backup_name = dbname+"-"+mode+" database backup" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
drop table #source ; | |
drop table #source_diff; | |
drop table #source_deleted; | |
*/ | |
declare @last_synchronization_version bigint; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE [dbo].[change_tracking_data]( | |
[id] [int] IDENTITY(1,1) NOT NULL, | |
[nama] [varchar](50) NOT NULL, | |
CONSTRAINT [PK_change_tracking_data] PRIMARY KEY CLUSTERED | |
( | |
[id] ASC | |
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] | |
) ON [PRIMARY] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlalchemy | |
from sqlalchemy.pool import NullPool | |
from sqlalchemy import text | |
def connect_sqlserver(): | |
user = "" | |
password = "" | |
database = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `pegawai_replicated` ( | |
`id` int(11) NOT NULL, | |
`nama` varchar(50) NOT NULL, | |
`jenis_kelamin` char(1) NOT NULL, | |
`is_deleted` tinyint(4) NOT NULL | |
) ENGINE=Aria DEFAULT CHARSET=utf8mb4; | |
ALTER TABLE `pegawai_replicated` | |
ADD PRIMARY KEY (`id`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE [dbo].[pegawai]( | |
[id] [int] IDENTITY(1,1) NOT NULL, | |
[nama] [varchar](20) NOT NULL, | |
[jenis_kelamin] [char](1) NOT NULL, | |
[create_at] [datetime] NOT NULL, | |
[update_at] [datetime] NOT NULL, | |
CONSTRAINT [PK_pegawai] PRIMARY KEY CLUSTERED | |
( | |
[id] ASC | |
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @table nvarchar(255) | |
declare @sql nvarchar(max) | |
-- setting table name | |
set @table = 'dbo.test' | |
-- adding starttime , endtime columns | |
set @sql = ' |