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 IF EXISTS #VENDEDORES_ATIVOS; | |
SELECT Distinct | |
B.COD_VENDEDOR | |
,B.CODIGO_FILIAL | |
,A.CPF | |
INTO #VENDEDORES_ATIVOS | |
FROM #TMP_VENDEDORES_ATIVOS A | |
INNER JOIN TB_AUX_LNX_VENDEDOR B ON LTRIM(RTRIM(B.CPF)) = LTRIM(RTRIM(A.CPF)) | |
WHERE | |
-- REGRAS CPFs VALIDOS |
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
rem Primeiro descubra o formato que o servidor está rodando o comando echo %date% | |
rem e aplique uma das funcionalidades abaixo | |
rem para PT-br | |
rem Transforma data em formato dd/mm/YYYY em YYYYmmDD, ou seja, 27/09/2021 em 20210927 | |
rem a ténica abaixo é basicamente um substring | |
set year=%date:~6,4% | |
set month=%date:~3,2% | |
set day=%date:~0,2% | |
set pt_br_today=%year%%month%%day% |
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
USE INTEGRADOR | |
GO | |
SELECT Dia, [Linx Venda] as Linx,[Integ. Venda] as Integrador,[L1 Venda OK] as Protheus, | |
[Linx Venda]-[Integ. Venda] as 'Linx - Integrador', | |
[Integ. Venda]-[L1 Venda OK] as 'Integrador - Protheus', | |
[Linx Venda]-[L1 Venda OK] as 'Linx - Protheus' | |
FROM (select Dia, Origem, QtdDoc from [VW_ConsultaIntegracao] where Dia > GETDATE()-3) as consulta | |
Pivot | |
( |
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
-- https://stackoverflow.com/questions/11186183/hash-a-sql-row/54789730#54789730 | |
drop table if exists #table1; | |
create table #table1 ( | |
campo varchar(10) | |
,campo1 varchar(10) | |
) | |
drop table if exists #table2; | |
create table #table2 ( |
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
--https://docs.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql?view=sql-server-2017 | |
-- 07/06/2019 | |
SELECT | |
SERVERPROPERTY('BuildClrVersion') AS BuildClrVersion, | |
SERVERPROPERTY('Collation') AS Collation, | |
SERVERPROPERTY('CollationID') AS CollationID, | |
SERVERPROPERTY('ComparisonStyle') AS ComparisonStyle, | |
SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS ComputerNamePhysicalNetBIOS, |
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
'use strict' | |
/* steps to use this test file: | |
1- install package lowdb : npm install lowdb | |
2- create a file empty data.json | |
3- manipulate the variable option to test the scenarios you want | |
*/ | |
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
-- #tags #sql #backup #bkp #sqlcmd #scheduler #windows | |
-- run this via batch | |
-- sqlcmd -S localhost -U [username] -P [password] -d master -Q "exec sp_BackupDatabases '[databaseName]','[typeOfBackup]', '[directoryToSaveData]'" | |
-- https://support.microsoft.com/en-us/help/2019698/how-to-schedule-and-automate-backups-of-sql-server-databases-in-sql-se | |
-- ============================================= | |
-- Author: Microsoft | |
-- Create date: 2010-02-06 | |
-- Description: Backup Databases for SQLExpress |
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
// Use this solution when we need to do an action when the request is finished | |
var myPromise = function(){ | |
return new Promise(function(resolve,reject){ | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET','https://api.github.com/users/brunotdantas'); | |
xhr.send(null); // if you have any parameters to complement the request | |
xhr.onreadystatechange = function(){ | |
if(xhr.readyState === 4){ |
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
--https://stackoverflow.com/questions/662383/better-techniques-for-trimming-leading-zeros-in-sql-server/662437#662437 | |
SELECT SUBSTRING(IDCLIENTE, PATINDEX('%[^0]%', IDCLIENTE+'.'), LEN(IDCLIENTE)) ,* FROM TB_IN_SAP_CUSTOMER WHERE CNPJ IN ( 'zzzzzz') |
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
/* | |
Solução pro erro: | |
Mensagem 1755, Nível 16, Estado 0, Linha 22 | |
Não podem ser criados padrões em colunas de carimbo de data/hora do tipo de dados. Tabela 'STG_MSAF_SALES_HEADER', coluna 'created_timestamp'. | |
Mensagem 1750, Nível 16, Estado 0, Linha 22 | |
Não foi possível criar a restrição ou o índice. Consulte os erros anteriores. | |
quando feito: | |
ALTER TABLE STG_MSAF_SALES_HEADER ADD created_timestamp timestamp default getdate() |