SQL Server Quick Tip: Restoring A Database Backup

Posted: May 1st, 2012 | Author: | Filed under: SQL | No Comments »

Restoring your SQL Server database using the GUI can leave your database stuck in the “restoring” state. One quick solution is to restore your database by using this simple SQL script.

RESTORE DATABASE your-database-name FROM DISK='c:\your\backup\file\and\path\backup.bak' WITH REPLACE

7/20/2012 Update

Here’s an updated version of the script that I use. I’ve also included my backup script.

-- restore it
use master
ALTER DATABASE [your-database-name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE 
RESTORE DATABASE [your-database-name]
FROM DISK = 'c:\your\backup\file\and\path\backup-to-restore.bak'
WITH REPLACE
ALTER DATABASE [your-database-name] SET MULTI_USER
 
-- back it up
BACKUP DATABASE [your-database-name] TO  
	DISK = N'c:\your\backup\file\and\path\backup.bak' 
	WITH NOFORMAT, INIT,  NAME = N'your-database-name', 
	SKIP, NOREWIND, NOUNLOAD,  STATS = 10

Model-Glue, Oracle and YUI

Posted: November 30th, 2009 | Author: | Filed under: ColdFusion, Flash, Frameworks, JavaScript, Model-Glue, SQL | No Comments »

I’ve been immersed in a world filled with Model-Glue Framework, Oracle 10g and YUI since June and am loving every minute of it. One of my goals for 2010 is to dust off this blog and resume contributing to the developer community. See you next year!


Writing and Calling Stored Procedures

Posted: May 12th, 2009 | Author: | Filed under: ColdFusion, SQL | 1 Comment »

In my previous post we built a Cheesy Database using simple SQL Scripts. Now I want to build on that by coding a stored procedure. Stored procedures are a ColdFusion developer’s best friend. You can use stored procedures to store some/most/all of your SQL logic. This is a great way to organize your code (stored procedures are generally faster than inline queries), optimize your application’s performance and help to protect your system from SQL Injection.

Writing a basic Stored Procedure is not a difficult task. First lets take a look at our inline query…

Read the rest of this entry »


Creating A Cheesy Database

Posted: May 12th, 2009 | Author: | Filed under: SQL | No Comments »

After reviewing my previous posts I thought that it would be helpful if all of my examples (1) worked and (2) worked together. So without further adieu, here are a few SQL scripts to get a basic database up and running. Once you’ve run these scripts you will be able to run the scripts found at my previous post on SQL Joins.

First we’ll create the database…

Read the rest of this entry »


SQL Joins

Posted: May 8th, 2009 | Author: | Filed under: SQL | 4 Comments »

Having spent most of my career working in environments where SQL development and ColdFusion development are handled by separate people or teams. The end result is that my SQL skills are not as evolved as my ColdFusion skills.

At my current job I am the one who writes the SQL for the small and medium-sized ColdFusion & SQL Server-based systems that I develop. Up until the other day I used implicit inner joins and over-used subqueries to get the data that I wanted from a database. My code worked, but it was ugly.

Read the rest of this entry »