Thursday, 8 October 2015

Example of how to duplicate rows in MySQL

INSERT INTO `document` (`filename`, `filepath`,`document_content`) SELECT `filename`, `filepath`,`document_content` FROM  `document`

Tuesday, 22 September 2015

Clear Windows Update Logs


1.        
·         net stop bits
·         net stop wuauserv
·         net stop appidsvc
·         net stop cryptsvc

Del "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr*.dat"

Friday, 7 August 2015

Blag

Elastic Search
NoSQL
HTML5
Extension Methods
Lambda Expressions
Razor @{}
Web API
Unit Testing (nUnit)
Deployments
Bootstrap
Angular
Knockout
Jquery
Moq

Friday, 31 July 2015

How to enable SFTP with Filezilla Server

By default, Filezilla Server does not support FTP via SFTP. However if can use SSL / TLS, commonly referred to as FTPS . It�s also a breeze to enable this in the Filezilla FTP Server Configuration. To do this, you simply have to do the following:
1.Access the Filezilla FTP server�s settings by going to Edit -> Settings.
filezilla-sftp
2. Once in the Settings section, you will need to scroll down to the SSL / TLS settings section.
3. Here you will need to check the �Enable FTP over SSL / TLS support (FTPS). Once you do this, the option to �Allow explicit FTP over TLS will be come available and Disallow plain unencrypted FTP� and �Force PROT P to encrypt file transfers in SSL/TLS mode. Be sure to check both.
4. Now you will need to click on the button �Generate new certificate..�. Once you do this, you will be presented with the following screen;
filezilla-sftp
5. Be sure to check check either 1024 bit, 2048 bit or 4096 bit. Since this is a self signed SSL, you can choose 4096 bit. Now you will need to fill out the rest of he required sections. Once you completed this, be sure to specify a valid location to save the key and certificate to. Once you have, click �Generate certificate�.
6. Filezilla server will now be setup to only use FTPS/FTPSE and will reject any FTP connections over port 21. Your new port will be 990. If you try to use conventional ftp to access the server, you may receive the error that you have to use explicit SSL / TLS before logging in.
7. You will now need to specify port 990 in order to log into the ftp server. Upon logging in, you will need to accept the SSL for the server now. You will have the option as well to always trust the certificate for future sessions.
filezilla-sftp
You have now secured Filezilla FTP server for use with only a FTPS connection. If at any time you wish to remove the SSL from the connection, simply log back into the FTP server and goto the SSL / TLS settings section and uncheck the �Enable FTP over SSL / TLS support (FTPS)� option.

Wednesday, 15 July 2015

Tidy WWW Log files and only keep the last 5 days worth

forfiles /P "C:\WINDOWS\system32\LogFiles\W3SVC1" /M *.log /D -5 /C "cmd /c del @PATH"

Recurse through a directory of Tif images and Compress them


for /f "tokens=* delims=" %%a in ('dir "C:\Directory" /s /b') do (

"C:\Program Files\ImageMagick-6.6.3-Q8\convert.exe" "%%a" -compress fax "%%a"

)

BCC Emails from Outlook Script

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim objRecip As Recipient
   
    Dim strMsg As String
    Dim res As Integer
    Dim strBcc As String
    On Error Resume Next
   
    ' #### USER OPTIONS ####
    ' address for Bcc -- must be SMTP address or resolvable
    ' to a name in the address book
    strBcc = "email@email.co.uk"
   
    If InStr(Item.SendUsingAccount.SmtpAddress, "email.co.uk") <> 0 Then
        Set objRecip = Item.Recipients.Add(strBcc)
        objRecip.Type = olBCC
        If Not objRecip.Resolve Then
            strMsg = "Could not resolve the Bcc recipient. " & _
                    "Do you want still to send the message?"
            res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
                    "Could Not Resolve Bcc Recipient")
            If res = vbNo Then
                Cancel = True
            End If
        End If
    End If

    Set objRecip = Nothing
End Sub

SQL to restore Admin database

alter database admindatabase set single_user with rollback immediate
go
restore database admindatabase from disk = 'C:\DBBackups\AdminDatabase_FULL_06292015_230003.BAK'
go

Upgrading and Installing TFS 2005 to TFS 2013

Install SQL Server 2008 R2
Copy Databases to TFSServer and Attach to local SQL Server
Install TFS 2010
Install SharePoint 2010
Follow wizard to upgrade from TFS 2005 to TFS 2010
Uninstall TFS 2010 after database upgrade
Install SQL Server 2012 SQL
Attach TFS databases which were previously attached to the SQL Server 2008 R2
Install TFS 2013
Perform another upgrade using the TFS 2013 wizard

SQL Server Backup Stored Procedure and Usage and also the Batch file

Batch File:

forfiles /P 
readynas\DevelopersBackup\SEARCHSERVER /M RoadKill*.* /D -20 /C "cmd /c del @path"
sqlcmd -U sa -P Password -S Searchserver -Q "EXEC sp_BackupDatabase @backuplocation='
readynas\DevelopersBackup\SEARCHSERVER\', @databaseName='RoadKill', @backupType='F'"
Stored Procedure:
USE [master]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sp_BackupDatabase] @databaseName sysname, @backupType CHAR(1), @backuplocation varchar(500)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @sqlCommand NVARCHAR(1000)
DECLARE @dateTime NVARCHAR(20)
SELECT @dateTime = REPLACE(CONVERT(VARCHAR, GETDATE(),111),'/','') + REPLACE(CONVERT(VARCHAR, GETDATE(),108),':','')
IF @backupType = 'F'
SET @sqlCommand = 'BACKUP DATABASE ' + @databaseName + ' TO DISK = ''' + @backuplocation + @databaseName + '_Full_' + @dateTime + '.BAK'''
IF @backupType = 'D'
SET @sqlCommand = 'BACKUP DATABASE ' + @databaseName + ' TO DISK = ''' + @backuplocation + @databaseName + '_Diff_' + @dateTime + '.BAK'' WITH DIFFERENTIAL'
IF @backupType = 'L'
SET @sqlCommand = 'BACKUP LOG ' + @databaseName + ' TO DISK = ''' + @backuplocation + @databaseName + '_Log_' + @dateTime + '.TRN''' EXECUTE sp_executesql @sqlCommand
END