Learn SQL With Bru
Bru Medishetty's SeekWell Blogs
Bru Medishetty's SeekWell Blogs
Oct 12th
The article has been submitted to a SQL Server community website for publishing in their articles. I am currently waiting for the article to be published. I am removing the current article from this site, will update here with the link to that article when it is published.
–Bru Medishetty
Oct 4th
Database Snapshots is a new feature introduced in SQL Server 2005. It provides a mechanism that enables us to save an exact read only copy of a database when the snapshot was taken. It would be highly beneficial that a database snapshot is taken when certain bulk changes to the table data is made or you need to maintain an exact copy of your database as it was at the end of the day, each day.
Some points to be noted while working with Database Snapshots.
Database snapshot can be created using T-SQL script only, it cannot be implemented using the Management Studio.
Script to create the Source Database
USE [master]
GO
CREATE DATABASE [Snapshot_Source] ON PRIMARY
( NAME = N‘Snapshot_Source_Data’, FILENAME =
N‘C:\Data\Snapshot_Source_Data.mdf’ , SIZE = 4096KB,
MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N‘Snapshot_Source_log’, FILENAME = N‘C:\Data\Snapshot_Source_Log.ldf’ ,
SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
Creating table called Demotable using the following script
CREATE TABLE [Snapshot_Source].[dbo].[DemoTable](
[Name] [varchar](50) NULL,
[Age] [int] NULL
) ON [PRIMARY]
Inserting records in the Demotable
INSERT INTO [Snapshot_Source].[dbo].[DemoTable]
VALUES ( ‘A’ , 30 )
INSERT INTO [Snapshot_Source].[dbo].[DemoTable]
VALUES ( ‘B’ , 35 )
INSERT INTO [Snapshot_Source].[dbo].[DemoTable]
VALUES ( ‘C’ , 37 )
INSERT INTO [Snapshot_Source].[dbo].[DemoTable]
VALUES ( ‘D’ , 40 )
Run the Following Script in the Query Editor
SELECT * FROM [Snapshot_Source].[dbo].[DemoTable]
CREATE DATABASE SNAPSHOT_01OCT2009_6AM ON PRIMARY
( NAME = N‘Snapshot_Source_Data’,
FILENAME = N‘C:\Data\SNAPSHOT_01OCT2009_6AM.ss’ )
AS SNAPSHOT OF Snapshot_Source;
GO
Modifying the Data in the Source Database.
Let’s modify the data in the source database by the following update statements.
UPDATE [Snapshot_Source].[dbo].[DemoTable]
SET [AGE] = 50 WHERE [Name] = ‘A’
UPDATE [Snapshot_Source].[dbo].[DemoTable]
SET [AGE] = 55 WHERE [Name] = ‘B’
Verifying the Data at the Source Database and also from the Snapshot by running the following script in the Query Editor.
SELECT * FROM [SNAPSHOT_01OCT2009_6AM].[dbo].[DemoTable]
SELECT * FROM [Snapshot_Source].[dbo].[DemoTable]
You can use a database snapshot in situations which needs a continuous read only copy of the database at a point of time. For example, you have a reporting application which requires data to be available and it is ok to have the data as it was at the end of day yesterday. A scheduled database snapshot of your transaction based Database which runs after the working hours each day would be a good solution.
Dropping a Database Snapshot.
Dropping a database snapshot is same as dropping a database, using the Drop Database command.
The following command would delete the database snapshot that was used in this example.
DROP DATABASE SNAPSHOT_01OCT2009_6AM
–Bru Medishetty
Sep 24th
In this article, we shall look at something that may not be done as frequently as you would want to. It is Downgrading a SQL Server 2005 from an Enterprise Edition to Standard Edition.
First you need to know why such an exercise is carried out any way. The reason would be, due to oversight, an Enterprise Edition was installed which in the first place must have been a Standard Edition, or the decision makers decide to go with Standard Edition of SQL Server due to the cost difference in the both the Editions.
Whatever the reason behind it, as a DBA you are asked to plan and carry out the exercise with a little or no downtime.
Here are the steps identified to perform the Downgrade to SQL Standard on the Same Server which has the SQL Enterprise. This method does not need any additional resources whatsoever.
Before beginning the process, make a note of the current Installation details such as
Steps to Perform Downgrade the SQL Server Enterprise to Standard
Please find the procedure described in the following TechNet Article for scripting Logins from one Server to another Server. http://support.microsoft.com/kb/918992/
This method would ensure that you need no additional resources, on the other side if something fails, you don’t have working SQL System to fall back onto. As always having a separate server where you can perform this would ensure that you have a Good working SQL Server in case of failure.
So it’s a Best Practice to have a plan to quickly revert to your old Installation or bring up the old SQL Server with Enterprise Edition.
–Bru Medishetty
Recent Comments