Category: SQL Server

  • Apply ALLOW_SNAPSHOT_ISOLATION and READ_COMMITTED_SNAPSHOT to SQL Server

    We needed to enable ALLOW_SNAPSHOT_ISOLATION and READ_COMMITTED_SNAPSHOT to specific databases on a SQL Server 2008 instance, I found to do this even with users off I was being shown errors stating it must be done in Single User Mode. I decided I wanted to do this as quickly as possible so slapped together some SQL…

    Continue reading

  • Add a user to DatabaseMailUserRole on msdb

    I had a user unable to use a script which generated an email, I found the user didn’t have permission, Microsoft state: To reduce the surface area of SQL Server, Database Mail stored procedures are disabled by default. To send Database Mail, you must be a member of the DatabaseMailUserRole database role in the msdb…

    Continue reading

  • Simple error checking when running batch files from T-SQL in SQL Server

    A while ago we added error trapping to the batch file called by a SQL script, this was to ensure if a program failed the rest of the process would not run: After ensuring the program would return an error level if something went wrong we then I then used the ErrorLevel and an if…

    Continue reading

  • T-SQL Get current Unix Time

    The following allows you to work out the current time on the Unix Environment. The Datediff function is used to work out the number of seconds between 01/01/1970 and the current date. I have used this against data which is stored and as Unix time. –Get current Unix datetime SELECT DATEDIFF(s, ‘1970-01-01 00:00:00’, GETUTCDATE()) as…

    Continue reading

  • Compress and move existing Windows 2012 and Microsoft SQL Server 2008 Express backups

    The following has been used to backup a server with Cisco Cubac on. The software runs on Windows 2012 machine and uses SQL Server 2008 Express. As its not on a managed server I had to find a way to backup the server and the database, plus keep the backup as small as possible. I…

    Continue reading