//
archives

Microsoft SQL

This category contains 8 posts

Reset SQL SA account password

Don’t know the SA password for your SQL server instance? Here are a few ways that you can reset the SQL SA account password should you ever need to. Both methods focus on getting a command window running as the SYSTEM account, and then launching SQL Server Management Studio (SSMS) from this window. This will … Continue reading

Restore SQL database from .bak as a different name

Follow the below to restore an MS SQL database backup (.bak) as a different name, changing the paths to the .bak, .mdf and .ldf files as appropriate in your environment. The only caveat with this is that the Logical Names of the database will remain the same as the database it was restored from, though … Continue reading

Database Consistency Check (DBCC) with daily report generation in MS SQL 2008 R2 & 2012

The following shows how you can automate the process of Database Consistency Checks (DBCC) for your MS SQL servers. This produces an email daily, weekly or monthly depending on how frequent you would like the checks to run and contains a link to a SQL Server Reporting Services report which displays a summary of the … Continue reading

Configure Database Mail in SQL Server 2012

Here’s a very quick guide to configure database mail for the first time (This should also work in MSSQL 2008/R2). You’ll need these beforehand: Valid email account IP address or host name of your mail server Mail servers SMTP port SQL Server Management Studio And here’s how to configure database mail (using SQL Server Management … Continue reading

Copy A Table From One Database To Another In MS SQL 2008

This can be useful if you’ve just restored a database from backup under a different name to the live database, and need to copy only individual tables and the table data from the restored database to the live one. Lets assume that the live database is called Live_DB and the restored database is called Restored_Live_DB … Continue reading

Restore MS SQL 2008 Database Backup (.bak) To A New SQL Server/Instance

Here’s how to restore an MS SQL .bak file onto a new SQL server/SQL instance with a simple script. I’ll show what to edit in the example below to restore the database My_DB.bak onto your new server First things first, if you have no idea what the database name and file paths are within your … Continue reading

Improving SQL Server 2008 Performance

I found an interesting document from Microsoft online which outlines some features in Microsoft SQL Server 2008 for improving performance and security (these features are only available in the Enterprise and Developer editions). The document describes tests carried out and also details the performance increases/decreases they observed after implementation. The document is available for download … Continue reading

SQL Search query example

It took me a long while to find out how to do this a few years back, it may be easier to do now than it was but I keep this code handy should I ever need it again. It basically lets you query MSSQL by passing optional search parameters (ClientId, ProjectID etc) and will … Continue reading