Red-gate has released another free e-book recently: Brad's Sure Guide to SQL Server Maintenance Plans. This book is all about maintenance plans and covers both SQL Server 2005 and 2008. The book is designed not to just talk on theories but the practical aspects of maintenance plans. It is written in a way that new and accidental DBAs can understand things clearly. I recommend this book as a must have to all DBAs.
As you all know red-gate is committed to bring better products and bring better DBAs to the society. They have produced some great tools, out of which I love SQL Compare and SQL Data Compare. They also support many SQL Server related sites including www.sqlservercentral.com and www.simple-talk.com. Through their continuous support SQL Server Sri Lanka User group (SSSLUG) is able manage the monthly meetings. In addition to that they also produce great e-books.
I have not finished reading this book yet, but I need to admit that this book is well written.This book talks about many things you can do with maintenance plans. If you are a DBA or want to be a DBA you need to study this book clearly.
Enough advertising :) You can get the book from this link
All about - databases and related technologies - things I work with - SQL Server, other relational & non relational databases, PowerShell and scripting languages.
Jan 19, 2010
Jan 17, 2010
24 Hours of PASS: you can view the sessions now!
I am not sure how many of you remember about the 24 hours of online sessions which PASS had a few months before the PASS annual summit. I attended a few sessions including Kalen’s topic: “What’s simple about simple recovery model ?” But I couldn’t attend all the sessions and I had a few technical issues in connecting to the site as well. They were online events and initially they were not available for on-demand streaming. A couple of days later a couple of sessions were made available for on-demand streaming and PASS promised that all sessions will be available for on-demand streaming after the PASS annual summit.
The sessions are really valuable and they cover various tracks such as Development (Dev) Database Administration (DBA) Personal Development (PD) and Business Intelligence (BI)
I forget to check them later, but a few days back when I checked the site, they were made available.
The sessions are really valuable and they cover various tracks such as Development (Dev) Database Administration (DBA) Personal Development (PD) and Business Intelligence (BI)
I forget to check them later, but a few days back when I checked the site, they were made available.
Jan 15, 2010
Lies, damn lies and statistics
I was thinking for a long time to write something about statistics. In fact, I even know what to write: How much statistics are reliable and how they affect the query execution plans etc. I even thought of a heading: which you see now. But some or other reason, I didn’t do it.
Finally now I made it.
Statistics is an internal mechanism used by SQL Server to make decisions on query execution plans. For example, assume that we have a query like this (I am using AdventureWorks database which came with SQL Server 2005. It is available for download from Codeplex)
We have an index on ManagerID. Now the issue is you will get two possible (most likely) execution plans generated.
Finally now I made it.
Statistics is an internal mechanism used by SQL Server to make decisions on query execution plans. For example, assume that we have a query like this (I am using AdventureWorks database which came with SQL Server 2005. It is available for download from Codeplex)
SELECT * FROM HumanResources.Employee WHERE ManagerID = 263
SELECT * FROM HumanResources.Employee WHERE ManagerID = 6
We have an index on ManagerID. Now the issue is you will get two possible (most likely) execution plans generated.
Oct 26, 2009
Here is the code for yesterday's Scenario:
create table #Department
(
DepartmentID int not null primary key clustered,
DepartmentName varchar(10) not null
)
create table #Employee
(
EmployeeID int not null identity primary key clustered,
DepartmentID int,
EmployeeName varchar(100)
)
insert #Department values(1, 'Sales'), (2, 'IT'), (3, 'Finance')
insert #Employee values (1, 'Sales Person1'), (1, 'Sales Person 2'), (2, 'Developer 1'), (2, 'Developer 2'),(2, 'DBA')
create table #Department
(
DepartmentID int not null primary key clustered,
DepartmentName varchar(10) not null
)
create table #Employee
(
EmployeeID int not null identity primary key clustered,
DepartmentID int,
EmployeeName varchar(100)
)
insert #Department values(1, 'Sales'), (2, 'IT'), (3, 'Finance')
insert #Employee values (1, 'Sales Person1'), (1, 'Sales Person 2'), (2, 'Developer 1'), (2, 'Developer 2'),(2, 'DBA')
Oct 25, 2009
How to "aggregate" on strings
If you need to get the sum of salary by department we may be able to use Sum and group by clauses in a single select statement to get it done. But if you have a situation where you need to give a comma separated string of employees for each department, how will you handle it?
Consider these tables:
Department Table
Employee Table
Now you want the results like this:
Consider these tables:
Department Table
| DepartmentID | DepartmentName |
| 1 | Sales |
| 2 | IT |
| 3 | Finance |
Employee Table
| EmployeeID | DepartmentID | EmployeeName |
| 1 | 1 | Sales Person 1 |
| 2 | 1 | Sales Person 2 |
| 3 | 2 | Developer 1 |
| 4 | 2 | Developer 2 |
| 5 | 2 | DBA 1 |
Now you want the results like this:
| DepartmentName | EmployeeList |
| Sales | Sales Person 1, Sales Person 2 |
| IT | Developer 1, Developer 2, DBA |
| Finance | NULL |
Oct 24, 2009
Catching row count and error number
After some days I am writing this blog.
I had a couple of training programs (total of 5.5 days) and then I need to travel to US (on official visit!) so I couldn't update the blog.
So here is the update.
If you need to track error number and row count of a statement how will you handle it?
Both of these are captured using @@ERROR and @@ROWCOUNT system variables.
But there is a catch:
They reflect the value of the immediate SQL statement irrespective of whether it is a DML statement (INSERT, UPDATE, DELETE & SELECT statements) or just a control statement. (Examples are IF, SET, WHILE) That means if you add SET @Err_Variable = @@ERROR after a DML statement, you will be able to catch the error number, but it will take the statement SET @Row_Variable = @@ROWCOUNT to return 1 always
How to resolve it?
I had a couple of training programs (total of 5.5 days) and then I need to travel to US (on official visit!) so I couldn't update the blog.
So here is the update.
If you need to track error number and row count of a statement how will you handle it?
Both of these are captured using @@ERROR and @@ROWCOUNT system variables.
But there is a catch:
They reflect the value of the immediate SQL statement irrespective of whether it is a DML statement (INSERT, UPDATE, DELETE & SELECT statements) or just a control statement. (Examples are IF, SET, WHILE) That means if you add SET @Err_Variable = @@ERROR after a DML statement, you will be able to catch the error number, but it will take the statement SET @Row_Variable = @@ROWCOUNT to return 1 always
How to resolve it?
Oct 11, 2009
For those use SQL logins
Today, I came to read about this blog. There seems to be a security issue if you are using SQL logins, but Microsoft says it is not an issue to worry about it. According to this post, Microsoft will not issue a security patch to resolve this problem.
Are you worried about this? You can read this article where it shows how things can go wrong and ways to prevent them.
Is SQL Server's latest security hole a real threat?test-security-hole-real-threat-801
Are you worried about this? You can read this article where it shows how things can go wrong and ways to prevent them.
Is SQL Server's latest security hole a real threat?test-security-hole-real-threat-801
Oct 10, 2009
The problem that prevented SQL Server from responsing
I couldn’t write for some time due to the heavy schedule I have. I was asked my Microsoft to do a customized training to one of their clients and it was a 4.5 day training. Preparing the materials took most of my time.
During this time I also went through some troubleshooting processes. Here is one of that:
A particular server failed to respond. Some DBAs tried to restart but the service could not be re-started. Agent was trying to stop before SQL Server stops and that was on waiting. At this moment I got a chance to work with them in resolving the problems. I tried to check on SQL Server error log. I couldn’t even connect. I checked with task manager where it showed that SQL Server was using only a few MB of memory (less than 1 GB) but CPU usage was 70% - 80%
During this time I also went through some troubleshooting processes. Here is one of that:
A particular server failed to respond. Some DBAs tried to restart but the service could not be re-started. Agent was trying to stop before SQL Server stops and that was on waiting. At this moment I got a chance to work with them in resolving the problems. I tried to check on SQL Server error log. I couldn’t even connect. I checked with task manager where it showed that SQL Server was using only a few MB of memory (less than 1 GB) but CPU usage was 70% - 80%
Oct 6, 2009
Gift from Quest
Yesterday, When I came from home I had a pleasant surprise.
Exactly one month ago, I wrote a post on free online training on SQL Server which was hosted by Quest. As I participated and filled the survey, Quest decided to honer me by thanking for my participation.
Of course I learned from the participation, But Quest surprised me with added stuff. Even though I participated only on two sessions, I received a Cd with all the sessions they had on that day. In addition to that I got two banners one on SQL server dynamic management views and the other on catalog views. To add, I also got a T-shirt on my size.
Of course the packet included some marketing stuff as well, but it gave me some advantage. As it was categorized as marketing material it bypassed the customs.
I went though the CD, it had the presentations and some additional documents. REALLY COOL stuff.
In summary, I gained by participating (the knowledge), I am gaining by participating (the goodies) and I will be gaining by participating. (I filled the survey so that future training programs will be more beneficial.)
Are you guys thinking of participating at the next training program?
Exactly one month ago, I wrote a post on free online training on SQL Server which was hosted by Quest. As I participated and filled the survey, Quest decided to honer me by thanking for my participation.
Of course I learned from the participation, But Quest surprised me with added stuff. Even though I participated only on two sessions, I received a Cd with all the sessions they had on that day. In addition to that I got two banners one on SQL server dynamic management views and the other on catalog views. To add, I also got a T-shirt on my size.
Of course the packet included some marketing stuff as well, but it gave me some advantage. As it was categorized as marketing material it bypassed the customs.
I went though the CD, it had the presentations and some additional documents. REALLY COOL stuff.
In summary, I gained by participating (the knowledge), I am gaining by participating (the goodies) and I will be gaining by participating. (I filled the survey so that future training programs will be more beneficial.)
Are you guys thinking of participating at the next training program?
Oct 4, 2009
Backup Process
Recently I had a question: What will happen to the transactions executed while a backup job is in progress? This question prompted me to learn more about backup process. Additionally I was asked to give training to a set of administrators so I wanted to be prepared with the answer before they ask the question.
There are a lot of articles in many sites about backup and restore and this article summarizes what I learned from those articles.
There are a lot of articles in many sites about backup and restore and this article summarizes what I learned from those articles.
Subscribe to:
Posts (Atom)
