Skip to content

Instantly share code, notes, and snippets.

View theSuiGenerisAakash's full-sized avatar
🎄
Holiday mood

Aakash Verma theSuiGenerisAakash

🎄
Holiday mood
View GitHub Profile
@theSuiGenerisAakash
theSuiGenerisAakash / em_cross_en.sql
Last active February 12, 2020 03:44
Perform any DML/DDL operations on selective tables, selective columns and a mix of those
-- A simple script that allows you to perform update and delete operations with optional where clause but mainly giving
-- you the flexibilty of doing so across multiple db, tables and columns
do $$
declare
selectrow record;
begin
for selectrow in
select
'DELETE FROM '|| t.mytable || ' WHERE ' || t.mytable ||'.sampledate > ''12-31-2018''' as script
@theSuiGenerisAakash
theSuiGenerisAakash / split_string.sql
Last active January 23, 2019 06:14
A UDF to split strings based on a delimiter in MySQL
-- Select your database
USE sample_database;
/* You might need to run this if MySQL says that the below function is non-determininstic (although I've added DETERMINSTIC keyword in it) */
-- SET GLOBAL log_bin_trust_function_creators = 1;
DELIMITER $$
DROP FUNCTION IF EXISTS splitString $$
-- Function splitString that returns a substring based on a certain delimiter's position
CREATE FUNCTION splitString (
x VARCHAR(255),
delim VARCHAR(12),