We have an old messy thirdparty application at work that uses Oracle. Sometimes the application tends to lock the Oracle system and use a LOT of threads, leaving the system pretty much unresponsive. To be able to kill all 1000+ Oracle-plus processes i created a small script that kills all processes.
Month: July 2017
Shrink transactionlogs
To shrink the MS-SQL transactionlogs for emergency storage needs we can use the following syntax.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
USE MYDB; GO -- Truncate the log by changing the database recovery model to SIMPLE. ALTER DATABASE MYDB SET RECOVERY SIMPLE; GO -- Shrink the truncated log file to 1 MB. DBCC SHRINKFILE (MYDB_Log, 1); GO -- Reset the database recovery model. ALTER DATABASE MYDB SET RECOVERY FULL; GO |
Use at your own risk.
Tablecopy with T-SQL
Today i found myself in a situation where i needed to copy some data from one table on a MS-SQL server to another. I found the following T-SQL syntax to be very helpfull.
1 2 3 4 5 6 7 8 9 10 11 |
UPDATE DST SET DST.Title = SRC.Title, DST.ContractNumber = SRC.ContractNumber, DST.ContractDescription = SRC.ContractDescription FROM Contracts AS DST INNER JOIN [SERVERNAME].[DBNAME].DBO.Contracts AS SRC ON DST.Id = SRC.Id where SRC.Id > 500 |
Use at your own risk.