Category: SQL

Nested Case Statements in SQL

Need to do nested Case statements in SQL? Use the following syntax. This should result in ‘a1b1 – yar’ This took me a little time to work out the syntax, but pretty simple once I understood case statements a little better. For some more info on case statements, you can go to the msdn  article located at http://msdn.microsoft.com/en-us/library/ms181765.aspx

Using Transactions in the Entity Framework (EF4)

You have multiple updates and want to implement transactions into your database updates in the Entity Framework? I had to do just that in C# , so I thought I’d share what I learn for to remember, and for you to learn. To do this, we must create a TransactionScope, and move around our save function a little bit in...

Automated Backups of Your SQL Database

Ever find yourself taking precious time and backing up all your databases, only to forget and be behind? I am currently working on some Alpha-PreAlpha software whose database structure changes with time like any other application. To solve the issue with remembering to back up however, I decided to automate it, and not have to worry. There probably is a...

How to Add, Modify, Rename, and Delete a Column in SQL

There has been a few times where I needed to compose a script to update a customer’s database, and I’ve had to use probably the most popular of the SQL ALTER TABLE syntax: Add, Modify, Rename, and Drop. To help save for my own notes and to possibly give some help,  I thought I’d write a quick article on these 4...

Delete or Truncate All Data in a Database

A quick tip for you all, ever need to delete or truncate all the data from a database? There has been a few times during testing after my database grew, that I needed a quick solution to clear a database. The solution is using the MSForEachTable stored procedure. Simply do the following : DatabaseName – The name of the database you...

Specify Your Own Select And Edit Top(n) in SQL Server Management Studio

When right clicking a table in SQL Server Management Studio, you have an array of options. Probably the two that I use most however is the “Select Top 1000 Rows” and the “Edit Top 200 Rows”. However, sometimes you want to look at a little more than that. I know most of the time I want to select all from...

Create a Filestream In SQL Server 2008 In Three Easy Steps

Step 1 : Enable FileStream The first step is to enable the filestream capabilities on your SQL Server instance. This can be found by going to your server properties in your SQL Server Configuration Manager and enabling the filestream there. Microsft explains how here. Step 2 : Creating a FileStream Database The following script will create a filestream database for...

%d bloggers like this: