Script SQL Server
Habilitar uso de aspas duplas
SET QUOTED_IDENTIFIER OFF
Tratamento de erros no SQL Server (TRY-CATCH)
Em linguagens de progamação como C# e Java, é comum o uso do bloco TRY-CATCH para tratar as exceções lançadas durante a execução das aplicações. Ao implementar Stored Procedures, Funções e Triggers, ou mesmo batches mais complexos, pode ser necessário tratar os possíveis erros ocorridos nos...
Backup SQL Server progress status in process
-- Sep 1 - Go to Task -> Back Up -> (Click in script) -> you will see it:BACKUP DATABASE [Database_name] TO DISK = N'pah_name.bak' WITH NOFORMAT, NOINIT, NAME = N'Database Backup Name', SKIP, NOREWIND, NOUNLOAD, STATS = 1 -- (change the stats from 10 to 1)The expected...
Backup Log - Truncate the logs at SQL 2005, 2008, 2012, 2014
--// To version before 2008 or upperBACKUP LOG [Database_name] WITH TRUNCATE_ONLYDBCC SHRINKFILE ( databasename_Log, 1)--// To version after 2005BACKUP LOG [Database_name] DynamicsGPWarehouse TO DISK='NUL:'
Date Functions - Day / Month / Minutes
--// Show the last date less 1 minuteselect DATEADD(MINUTE, -1, DATEADD(DAY,1,getdate()))--// Show the first day from the last monthSelect DateAdd(mm, DateDiff(mm,0,GetDate()), -1) as [Último dia no mês Anterior]--// Show the last day from the last monthSelect DateAdd(mm, DateDiff(mm,0,GetDate()),...
Calling a Package or Function or Stored Procedure from Oracle by Linked Server
EXEC ('BEGIN ACTIVATE.act.activate(I_SERVICE_ID => ?,I_MEDIA_CODE => ?,I_MACHINE_CODE => ?,O_RESULT =>?,I_SOURCE_DETAIL=>?,I_SOURCE=>?); END;', @iServiceID, @vchMediaCode, @iMachineCode, @vchResult out , @vchSourceDetail, @vchSource) at...
SQL Server service crashes when you run an Oracle linked server query
Let me just to share with everyone, I found out the cause why it happened and it's helpful to don't happen again with our team!Cause is it "- -" + Oracle Linked ServerSample - cause problem code:--// Oracle Linked ServerEXEC ('BEGIN ACT.ACTIVATE(?,?,?,?,?,?,?); END;', @iServiceID,...
Delete huge data without index - Datawarehouse
--// SAMPLE 01=========================1 - Include a field integer=============================================================Alter table tArch_PrintDocument Add createDateInt int2 - Insert data from CreateDate field (it will increase...
Show IP connection and port network (connected) by DOS
netstat -narp -a
Test conection port network - DOS - Network
telnet ip_number:port_number