Skip to content

Instantly share code, notes, and snippets.

View tkMageztik's full-sized avatar

Juan José Ruiz de Castilla tkMageztik

View GitHub Profile
@tkMageztik
tkMageztik / fin_strange_characters_db2
Created October 20, 2016 20:11
Para buscar caracteres extraños fuera de la lista de caracteres especificados
SELECT * FROM BFPCYFILES.CUMST c
WHERE
cuslgt IN (2,4) and
cusna1 LIKE '%*%'
AND ASCII(TRIM(TRANSLATE(
cusna1,
' ', -- empty string
'*()0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
))) not in (10,64)
@tkMageztik
tkMageztik / MERGE_DB2_AS400
Created October 20, 2016 19:44
UPDATE INNER JOIN MEDIANTE MERGE
MERGE INTO BFPCYFILES.CUMST A
USING (SELECT * FROM libjuarui.CUMST_b ) B
ON A.CUSCUN = B.CUSCUN
WHEN MATCHED
THEN
UPDATE
SET
A.CUSNA1 = B.CUSNA1,
A.CUSSHN = B.CUSSHN,
A.CUSLN1 = B.CUSLN1,
@tkMageztik
tkMageztik / gist:99fde9635f883a66d7d87f008007fcd6
Created October 10, 2016 21:09
Recuperar acceso SQL sin pass.
Para recuperar permisos en BD SQL Server
OPCIÓN 1: Mediante programa PsExec v2.11
Fuente: https://www.mssqltips.com/sqlservertip/2682/recover-access-to-a-sql-server-instance/
Problem
Starting with SQL Server 2008, the local Administrators group is no longer added by default during SQL Server setup; you even have to use a manual step to add the current user as a local administrator. This means that it is possible, especially if you don't use mixed authentication (or have forgotten the sa password), that you can be completely locked out of your own SQL Server instance. I've seen cases where an employee has moved on, but their Windows account, being the only one with Administrator privileges for SQL Server, had been completely obliterated from the system. Of course that person was the only one who knew the sa password as well, and being a local admin or even a domain admin might not help you.
The typical workaround I have seen employed is to restart SQL Server in single user mode. However, this approach requir
@tkMageztik
tkMageztik / gist:460f8921bfeb72ffa2739ce762275ff9
Created October 4, 2016 20:55
Sustento del uso de Constantes > HardCoding
selfdocumenting code
softcoding anti-pattern
magic numbers.
hacer un mantenimiento que no se tiene que implica desarrollo y que 95% no se va usar... .
cuando es una constante y cuando es código en duro?
@tkMageztik
tkMageztik / gist:4c8ad3a124b4c7da3eaf9db145426c5b
Created September 21, 2016 02:27
Browsers render engine and CSS-prefix
http://stackoverflow.com/questions/3468154/what-is-webkit-and-how-is-it-related-to-css
@tkMageztik
tkMageztik / gist:16bb4b7000278518e44f6ec47f04be75
Created September 7, 2016 21:10
Para crear un constraint UNIQUE que permita nulos, en su lugar crear un índice NONCLUSTERED. MSSQL 2008+
CREATE UNIQUE NONCLUSTERED INDEX BFIN_BFBMM01_CLIENTES_CUENTAS_02
ON BFBMM01_CLIENTES_CUENTAS(M01_NRO_CTA_IBS)
WHERE M01_NRO_CTA_IBS IS NOT NULL
GO
@tkMageztik
tkMageztik / link.txt
Created April 28, 2016 21:36
Caracteres que van después de la Z, para poder emular el NULLS LAST en SQL SERVER.
@tkMageztik
tkMageztik / varios.txt
Created April 13, 2016 15:05
Para darle color a las filas de un gridview en el databound, entre otros formatos ...
//e.Row.Attributes.Add("style", "cursor:help;");
//if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState == DataControlRowState.Alternate)
//{
// if (e.Row.RowType == DataControlRowType.DataRow)
// {
// e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='orange'");
// e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#E56E94'");
// e.Row.BackColor = Color.FromName("#E56E94");
@tkMageztik
tkMageztik / recommended_indexes.sql
Last active March 18, 2016 23:05
Muestra recomendaciones de las tablas a las que se les deberían cread índices y cuales deberían ser.
@tkMageztik
tkMageztik / BuscaValorEnBBDD.sql
Created March 18, 2016 17:20
Busca un texto en todas las columnas de todas las tablas de una BD SQL SERVER
CREATE PROC BuscaValorEnBBDD
(
@StrValorBusqueda nvarchar(100)
)
AS
BEGIN
CREATE TABLE #Resultado (NombreColumna nvarchar(370), ValorColumna nvarchar(3630))
SET NOCOUNT ON