Becoming a DBA

This is in response to John Sansom’s call for posts describing a DBA story. Here is mine –
1 How did you get started?
I was working as a Visual Basic programmer in a leading financial company on Wall Street in the 90s. Despite being a large company with sensitive data they did not have a dedicated DBA – my boss managed a team of developers and did most of the DBA work himself. He was often overwhelmed with many things to do. I offered to learn some of his work, particularly DBA work since databases interested me. He taught me basic dba tasks – how to do backup/restore, how to create and maintain databases and certain other things that were specific to that business. He greatly appreciated my help despite having a lot to do myself. The story went well with both of us helping each other. One day it so happened that he was working late. The company had requirements for people to work late during monthly closes and it was one such night. He decided to go for a walk to give himself a break and walked into a bar. He got back in after a drink too many and dropped a mission critical database, bringing all the activities in the company to a standstill. Those were days when we did not have capabilities to log in remotely or even cell phones – so the phone in my home rang at 2 am. I was asked to get in to work immediately as it was an emergency. When I went in I learnt the story and also that he had been fired. I was able to restore the database and apply the logs. They had only lost 15 minutes worth of data and they were happy. With that came the keys of my first DBA job, and I have not looked back since.

2 Describe what a typical day is for you?
I currently work as a senior DBA in a leading healthcare company. I manage about 150 servers, with a team of 3 other DBAs. A typical day begins with a quick scan of our ticket queue – there may be tickets for failed jobs, backup failures, space issues or login problems. Sometimes these are small issues fixed easily, sometimes they may take longer depending on nature or complexity. Most of our alerting system and ticketing system is automated eliminating the need for checking individual servers since we have many. Following that is checking the queue for change management requests. These may be requests for backups, restores, promotions and the like. Most promotions involve code reviews for standards compliance and also performance – like usage of hints, appropriate indexes and so on. This may take a few minutes or a whole day depending on size of the request. Then there may be meetings to attend – a new application to be rolled out, a server upgrade to a newer version, a standards revision and so on. There may be documentation and internal team discussions on new features of SQL 2012, patches and service packs, scheduling off hour work and so on. In short, rarely a dull moment and lots of opportunities to learn and grow.

3 What advice would you give to someone considering becoming a DBA/DB Developer?
It is probably the same advice I would give to anyone who wants to be good at what they do. Brent Ozar said it very well in a post on time management sometime ago – ‘Decide you want to be incredible’. I have worked in many jobs and most of the time I would look to my collegues and friends to be as motivated as I was. Many people just want a job – they will go to a training if their boss sent them, browse the internet most of the time there too, do their jobs on a purely task basis, go home on friday, return monday, take the yearly vacation and go on again. I got a lot of attitude and a lot of ‘looks’ from people when I got excited about the latest release of SQL Server or the latest great book out there or even if I stayed late trying to fix a query to run faster. It took me a while to get it that if I had to excel it was time to ignore all that and do what is right for *me*. Passion is nothing to be ashamed of, and if you feel a passion for what you do – grow it and find places that will support it. Grow out of the need to be like ‘them’ and you will find more people like you who will inspire and motivate you to be better.

TSQL Tuesday #31: Logging: Case of the Missing LSN

 This is in response to Aaron Nelson’s call for T SQL Tuesday – on the subject of Logging. There are many things that come to a DBA’s mind while talking of logging. For this I chose an incident that happened some years ago. I had joined a new job, and the dba who had taken my spot had been there for several years before she left. She had set up most of the maintenence jobs on existing servers, most of which were on SQL Server 2000 then.

On the second day of my job I was asked to restore a backup as of a certain date/time to a development server to recover some data for an application manager. I was directed to the place where backups were stored. I found the full backup, and hourly transaction logs following that. As I set about restoring, I got a certain log that gave me a missing LSN error. The log job was set to run hourly, and the timestamps showed all logs were there and there were no errors on the job. I looked further to see if anything else was going on at that time when the log was backed up – I found a reindexing job in which the recovery model was being set to simple and back to full again. In 2005 and above if this change is done – the log chain is broken and one gets an error that a full backup is needed before restarting it. But in 2000 there was no such thing. The log chain was still broken but the job was not throwing any errors to show that. The backups were just not usable.
The process had been in place for more than 4 years, and luckily there had been no requirements to use the transaction log backups during this time interval. They even had a testing mechanism for testing backups, but they did not test backups during this particular sequence of operations. After that episode I also changed the testing process to work through job cycle – through all jobs and maintenence windows, in case there was any issue. It was a great lesson for me on backup testing and how many issues can remain dormant for years until one gets them accidentally. Luckily it was not a crisis situation when it was discovered but it might very well have been. Test your backups, and through jobs and processes as necssary, not just during small windows.

SQL Cruise Alaska 2012

I had the good fortune of joining the SQLCruise this year. Below is summary of my experience. I plan to write more detailed posts since there is so much I learnt both personally and professionally, but just had to get this out soon.

Countdown: I landed in Seattle on Thursday, May 24th. In the evening I did a tour of Seattle underground – during this tour got acquainted with fellow cruiser Wayne Sheffield and his family (wife,mom and m-in-law). They were great company on the tour and also in the days that followed. On Friday I did a tour of Snoqualmie falls – which included a visit to two wineries and a chocolate factory.The day ended with SQL Cruise kick off party – which was great fun and organized very well by Tim and Amy Ford. There was food for every taste and lots of fun games/prizes too. I picked up a few of Red Gate swag books for the user group and myself (thank you Red Gate). I left the party early since the next day seemed busy and was still suffering east coast jet lag.
Day 1: I took a cab to the pier around 11 am. The cruiseline promptly took over the luggage and I joined a big crowd of people waiting in the building outside the ship. I met with several fellow cruisers there and the wait was not long before we were called to check in. The check in process was simple – only involved a brief overview of passport and cruise documents, and one was issued tickets and other necessary stuff. By noon we were allowed to board the ship although our rooms were not ready. We were also allowed to eat lunch. It was an awesome first lunch on the sunny deck overlooking seattle harbor with a light breeze blowing in, with several friends for company. The ship took off by around 4 pm – and we were allowed to get into our rooms at the same time. After a short nap/rest everyone was ready to go for the Red Gate discover the ship contest – a fun game where we get a list of things ‘to do’ on board the ship that helped us explore various areas as well as get to know our partners well. I was paired with Jes Borland and her husband Justin – we had a great time getting around the ship and talking to various people for taking pictures with them. Jes is a natural extrovert and just being around her made me feel very upbeat, not to mention the fun we had going around various areas of the ship. By the time the contest was done we were tired – although we did not win the prize it was designed really well and thoroughly enjoyed it. The next day seemed packed with training so retired early.
Day 2: The day started with Brent Ozar‘s presentation on Procedure Cache BI. This is an area I work with a lot – I greatly enjoyed the presentation and discussion that followed. After lunch we continued with Kevin Kline‘s presentation on Leadership Skills for IT Professional. I learnt many things from this, also re confirmed my own assessment of myself – that I would probably do well as a technical expert than a manager. The class was also very interactive and we discussed lots of different scenarios ranging from outsourcing problems to difficult bosses.Kevin also mentioned the Quest give away of a whole suite of tools to all sql cruise attendees  – since I use almost all their products I asked if I could raffle this away at my upcoming SQL Saturday. I think very highly of Quest tools and this is a great give away.  In all this was a great and very enjoyable day. 
Day 3: We landed at Ketchikan bright and early at 7 am. I took a boat tour of Misty Fjords, which lasted 3 hours. The boat went through some amazing landscapes with misty cliffs and silvery waterfalls all around. We also saw some seals, eagles and bears en route (too far away for my little point and shoot camera to capture :(. After lunch we had a session with Allen White on SQL Sentry’s Plan Explorer – an excellent free tool that am already using. Allen showed many scenarios that the tool can be used with which I was not aware of. That was followed by Jeremiah Peschka‘s presentation on Killer Techniques for Database Performance. I was particularly struck by a difference he found between developer and enterprise editions on handling indexed views, and also by the ‘goats in the tree’ funny calender which I plan to order soon :)) Jeremiah also explained of how benchmarking can be doctored for any environment. I have always found his presentations to be funny and informative and this was no exception. The day ended with a fun dinner with several other sql cruise-ers.
Day 4: This day began with 3 glacier helicopter tour at Juneau. Standing on top of a glacier, the ponds of blue ice and the amazing serenity are highlights of my trip and sights i will cherish for a very long time. We spent the afternoon in the suite rented by the BrentOzarPLF team. The views from the suite was amazing. We had a story telling contest where many participants shared their stories of memorable work experiences – Darcy Williams won a Kindle fire prize for her simple,down to earth story.  Brent made mention of every one of our stories and gave each of us a gift that seemed to tie in with our stories in some way. He also took time to do a brief intro summary of his rather famous pre con professional workshop, which seemed informative in itself. That afternoon was great community time teamed up with amazing scenery as the ship sailed through the glacier.
Day 4: We docked at Skagway in the morning. I could not do the hike i had planned earlier due to some minor health issues – but the cruise line kindly accomodated me on a train ride to White Pass in the afternoon. The morning was spent shopping at the amazing art stores in downtown Skagway. The train ride was the best I had ever had in terms of scenic beauty, have a hard time even describing how awesome it was. The skagway break was long and we did not have any class this day.
Day 5: After 4 days of sight seeing this was a day of hard core training and began with Allen White‘s Introduction to Powershell. As someone who has not used much of powershell I learnt a lot from this. Allen also provided several useful links/info on blogs and books for those wanting to learn more on the subject. This was followed by Kendra Little‘s presentation on Sports Medicine for High Transaction Databases – she talked of baselining strategies for busy databases, how to find windows to do maintenence, and several other tips and tricks. The day ended with Robert Davis‘s presentation on backup and recovery strategies.
Day 6: The last day began with Brent Ozar’s presentation on Scaling SQL with Solid State. It was packed with great information on Solid State/Hard drive layout and various strategies to get the best out of it. It was a tough subject for me and i cannot claim I understood all of it but it seemed like a great start to learn more and plan to revisit these slides again soon. The training concluded with Idera Iditarod challenge – a clue based ship search with some sql questions thrown in. I was partnered with Max Gomeniouk. Max was an extremly  agile creative person who handled the ship search swiftly and well, while I fielded the sql questions. Between us we made a good team and managed to win the prize – a Kindle fire, a great start to my ebook reading habit. Thank you Idera for the well designed contest and the wonderful prize!! The afternoon was spent at Victoria, Canada –  I had dinner again with Kevin and his lovely mom Shirley and bid good bye to them.

In conclusion – you can perhaps count the number of times the word ‘amazing’ and ‘awesome’ appears in my post – that is perhaps an indicator of what a great trip this was. It is not easy to organize a training aboard a cruise ship – there is very minimal electronic communication, which is what we use most of the time for events, there is no ‘common’ place where one can post timetables or itineraries and it is hard to find people when you need them. Despite all these challenges Tim and Amy Ford designed a near flawless schedule with awesome trainers and great networking.

From the time i set foot in the boarding room on Day 1 until the time I actually got into a cab to the airport (oh no wait, I met a couple of people at the airport too 🙂 I was talking and socializing with someone from the group, and that in itself speaks for what a well knit, cool team of people we were together. Do consider the next SQLCruise on your travel/training agenda, it is worth every dime you spend. I surely am considering going on the next one,  already :))

My 3 priorities.. and SQLCruise

I was reading a link recommended by Kevin Kline on Getting Results the Agile way. This author talks of thinking in 3s- setting goals and priorities in 3s and watch how you meet them. If I were to think of 3 things i need to do every year to get ahead in life/career – what would they be?  Mine are as below –

1 Take a vacation – Seems odd that that is the first thing to say for career growth – but to me it is . I was a die hard workaholic for several years in my life – used to think I carried the place on my shoulders, and worried about every single thing that could go wrong if ‘I’ wasn’t around to fix it. Needless to say that didn’t get me anywhere. I ended up really sick with overwork twice, and once even getting fired because the guy on top didn’t like my work ethics (there was more to it than overwork but that was one of the reasons). But after all that the lesson I have learnt is that time away from work is important. Also to add to that – when one reaches mid age one realizes in a very real way that time is limited. That bucket list of places to see and things to do needs to be looked into atleast one a time…after that realization I make it a point to go somewhere atleast once a year and spend two weeks away from work. Sometimes it is my home country, India, sometimes it is other places.

2 Network – I had a speaker in my user group sometime ago. He used to ask me often if I ‘understood’ how networking worked, since he was a rather introverted person himself. After every talk he gave and every meeting he attended he would ‘count’ how many people he had met and if he had gained anything from them. Needless to say after a few meetings he decided there was nothing to this and gave up. I was of the same mindset as this man for a while, since i am also somewhat of a private person and it is hard for me to be ‘out there’…but I was willing to give it a better shot than he. I started the user group locally and after running it for two years – I was approached by someone who attended my meetings with a great job offer. The next two jobs I have landed have been via people I have met, and mostly via conversations rather than formal interviews and resume applications. Networking takes time and effort, but networking pays huge dividends if one is patient and persistent with it. Networking is something I consider I should do with more focus and more diligence as I grow older.

3 Attend as many trainings as possible – As a production DBA I must admit the time I have to learn on my own is somewhat limited. It would be great, as Brent Ozar said once, if the learning is part of the job itself but most DBAs struggle with a lot of operational work – you don’t do cool jazzy stuff every day, you have to do repetitive things and have to attend to a lot of things outside work hours. So the only way really to keep up with learning is to attend trainings – as many trainings as possible. I am a train-a-holic – be it free trainings or paid trainings (my company is generous with paid trainings) – I am there, opening my ears wide to gain as much knowledge as I can possibly gain.

So..the three priorities defined – I found a place where all three can be accomplished in one shot. The SQL Cruise. I get to see Alaska, a place that I have longed to see since I saw pictures of glaciers in my sixth grade geography textbook. I get to network, with some of the most successful and best people in the SQL world (The BrentOzarPLF team, Allen White, Aaron Bertrand,Kevin Kline….). I get to train with them too. Can’t think of anything better that would fit my needs this year and counting every day down to the cruise.

Managing time – a renewed perspective

My favorite book on time management was Stephen Covey’s ‘First Things First’. I say ‘was’ because it has been years since i read it and longer since i used it. There are random quotes and ideas from that book that still stick with me (‘The main thing is to keep the main thing the main thing’,
Sharpen the saw’,’What lies before you and what lies behind you are
much smaller than what lies within you’) and perhaps that is the best i will get out of it. In general, I don’t do well with a lot of structure around time. I don’t think many people do. You can’t run life based on a list – there will always be stuff that is not there, things that get in the way, and many times, you are just plain tired and want to let things be. Covey in fact warns about life becoming one task list after another,and that is exactly what I was facing in this past month. The number of things on my tasklist seemed getting longer and my time getting shorter. Somewhere down the line the focus was lost. I came upon Brent Ozar’s post on time management (http://ozar.me/2012/03/my-6-rules-for-incredible-time-management/) that made huge sense to me during this time. I am writing below on what each of his points meant to me and how I plan to handle my time better.

As a disclaimer, I don’t think many of these will work as is for me. If it did I’d probably be like Brent in my career (MCM and top notch speaker/blogger), and I am not. I have however found it motivating to use long term, infused with the pragmatism it needs for my own needs.

Rule #1: Decide that you want to be incredible. 
The first thought that came to my mind and question I would have asked myself sometime ago is – doesn’t everybody? But from lessons learnt the hard way – no, not everyone wants to be incredible. Atleast not at their careers. They have other priorities/interests, such as families or other hobbies, and that is totally okay. But the cynicism and negativity in many workplaces is so high that words like that are often met with disbelieving snorts and chuckles by most people. ‘I just wanna go home’ or ‘oh please’ would be the most common answer. I am fortunate to work at a place where people do want to learn and training is given the priority it deserves, but that has been my experience in many places. In fact you do not belong if you think higher than they do. 
Takeways: Rise above the cynicism,do not share hopes and dreams with those who have none.

Rule #2: Never budget less than whole-day increments of time.
Can’t believe how grateful I am to hear this articulated..I attended a SQLSkills class early this month. For one week we were in a classroom, with no internet, no cell phones and no distractions. We were purely on a learning high – I find it hard to even say how good that felt , how much I learnt and how well. I often wondered about why I don’t feel that way when I learn on my own – either by reading a book or working on my own lab or watching a video. I get tired easily, want to check out facebook updates, get on twitter, or call a friend. I think i know why, am doing it in really small chunks of time. The bull is not ‘seized by his horns’ , he is wandering around somewhere and can get away real soon. This also somehow ties in with Pomodero technique that Buck Woody recommended (although that is for small chunks of time) – that technique calls for getting comfortable with clock ‘ticking away’,instead of being stressed by it. Both are about focus and getting things done with passage of time. I would say that I am considering ‘big’ increments of time, say 3-4 hours instead of half hour-45 mins – to me particularly that needs to be done for learning and blogging, since that is two areas I want to improve upon.
Takeaways: Experiment with  a bigger chunk of time with a clock.

Rule #3: Leave one whole day per week to do absolutely nothing.
I can proudly say this is one rule I have been practicising a while now and plan to keep. Sunday is ‘my time’ – when I just relax and do what comes to mind, reading,digging in my yard and napping.I also try to keep it offline day, just to get a taste of life without computers running it all the time!!. In short, just plan to keep this one going.

Rule #4: Leave one more solid day per week to pounce on incredible opportunities.
I have been running a user group for 8 years now and organized 4 sql saturdays with #5 en route. This is something I enjoy  and plan to keep doing. But I have not done enough of presenting, especially given the fact that I have an audience to practice on in my own user group.That is an ‘incredible opportunity’, to devote time on. Volunteering does not need one day every week, it comes and goes..during big events it needs more than a day, during normal times perhaps an hour or less. But with more presenting it might take upto half a day..and ties in with #2 – ‘big increments of time’, rather one one more solid day.
Takeaways: Put ‘chunk’ of time into presenting for user group.

Rule #5: If the incredible opportunity runs more than a few weeks, it’s work.
Learnt this the hard way. I cannot study for 2012 beta exams and 2008 mcm knowledge exam at the same time. I cannot volunteer for reviewing speaker extracts and organising sql saturdays at the same time. In short , a lot of things sound sexy but are not doable given the fact that time is limited. Many of them end up as ‘Well begun is half done’. I can prepare for one exam (right now it is the development MCITP which is a pre requsite for the MCM Knowledge exam) and do one volunteering activity (SQL Saturday). After those two are out fo my way I can add on one more in each category but not before.
Takeaways: Get clear on what to do and stick with it, can’t do it all.

Rule #6: Say no early and forcefully to everything else.
Taking on too much is a nasty habit I have been working on kicking, and had some luck this year. It does come with some pain though. I said no to some of things I greatly enjoy – one of them is reading fiction, second is doing an art class (painting/cartooning). Much as I love these things I don’t have time – and if i have to get ahead with SQL some sacrifices have to be made. Doing a little of everything is tempting, but again goes  back to point #2 – the bull wanders away. That is all. (The ‘bull’ as of now is preparing for the development MCITP).

Perhaps the biggest motivator to me is what Brent said about sharpening the saw – or staying up to date on skills. ‘For me, studying and keeping up with technology is part of my work.’. That is what I’d like my work to be – I made a decision 5 years ago that I would not work for a place that did not support a minimum of two solid trainings or conferences per year. That has worked out fine, and helped me hugely with staying up to date. But for me, and for a lot of people, there is a huge element of operational day to day stuff that is part of our jobs and takes away from time we like to use to learn. Production DBAs cannot get away from that easily – it is when you ‘set aside’ time for something that the cluster goes down, or the NOC calls you for some kind of ‘database issue’. Getting to a place where learning becomes part of one’s work is a reward in itself, that speaks volumes for how creative and involved the work is. The goal is to get accomplished enough to deserve that kind of work.

Thank you Brent, for the inspiration.

Meme Monday – February – Working with deadlines

This is in response to Thomas LaRock’s invitation for Meme Monday:

The strategy that works best for is to break the tasks involved into as much detail as possible…so that it makes the final deadline seem far less threatening. I try not to ponder too much on the final product, but work the detail diligently and try to make progress that way.  As a child my father always gave us the example of ants building an anthill – each of them does its job of carrying little pieces of mud/rock, they do not waste time contemplating the big end product. But finally it gets done. I begin with the end in mind, as the saying goes, but like to forget the end until it actually gets close and focus on the detail.

I also attempt not to commit to unrealistic deadlines or set such deadlines for myself. This is something I have learnt the hard way..being a very detail oriented type A person I have set several unrealistic deadlines for myself, and learnt the hard way that they are not doable. There are two issues with setting a realistic deadline – one is having a hard conversation on how much I can do. If my deadline is to attempt a certification, say, how many hours of study can I do? At the end of a long working day, with all home chores done, realistically, am lucky if I do an hour of focused study. If I get too optimistic and make it two I usually wind up getting stressed around finding the two hours and not doing any at all!!  (For work goals it is more around scheduling all the other tasks and explaining honestly to my boss – sometimes he takes something off my plate to help me find more time). The second thing is how much I can do in the given time. In one hour of study time I can probably read a chapter of a book really well..or a portion of the chapter, depending on complexity of the book. Some of this depends on intuitive feel, some of it is plain common sense. So with a good combination of how much i can do and what i can do i can arrive at a good estimate. After that it is just being disciplined and diligent about it. There is nothing better than the good feeling that comes with getting to one’s deadline on time, and having the task done well..that feeling itself is a great motivator.

T-SQL Tuesday #025 – Invitation to Share Your Tricks

This is my first response to a TSQL Tuesday.

There are lot of things in TSQL that can be done to make DBA’s life easier. We have a large collection of scripts. These are some I have used over the years at multiple jobs – there are several more but I don’t particularly want to write a very long post. Also a disclaimer that I did not write all of them.  I wrote some,  I tweaked some I found on sites like SQLServerCentral.com that have come in very handy. I apologize ahead for not offering credit since I have not kept track of the authors.

–Find the last server start date(2005)
SELECT crdate AS Datetime_Started FROM sysdatabases WHERE name = ‘tempdb’

1 –Find Blank passwords
SELECT name FROM sys.syslogins WHERE pwdcompare(””, password) = 1

2 –Find members of a role (for example, public)
SELECT a.[name] + ‘ ‘ + v.[name] + ‘ ON ‘ + QuoteName(oo.[name]) + ‘.’ + QuoteName(o.[name]) + ‘ TO ‘ + QuoteName(u.[name])
FROM dbo.sysprotects AS p JOIN master.dbo.spt_values AS a
ON (a.number = p.protecttype AND ‘T’ = a.type) JOIN master.dbo.spt_values
AS v ON (v.number = p.action AND ‘T’ = v.type) JOIN dbo.sysobjects AS o ON (o.id = p.id)
JOIN dbo.sysusers AS oo ON (oo.uid = o.uid) JOIN dbo.sysusers AS u ON (u.uid = p.uid) WHERE ‘public’ = u.name

3 –Find number of times a stored procedure was used since last reboot
SELECT DB_NAME(st.dbid) DBName
,OBJECT_SCHEMA_NAME(st.objectid,dbid) SchemaName
,OBJECT_NAME(st.objectid,dbid) StoredProcedure
,max(cp.usecounts) Execution_count
FROM sys.dm_exec_cached_plans cp
CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) st
where DB_NAME(st.dbid) is not null and cp.objtype = ‘proc’
group by cp.plan_handle, DB_NAME(st.dbid),
OBJECT_SCHEMA_NAME(objectid,st.dbid),
OBJECT_NAME(objectid,st.dbid)
order by max(cp.usecounts)

4 –Stick in anything to be changed across all dbs (just used sp_dboption with read only here)
SET NOCOUNT ON

— Get the name of all databases
DECLARE UserDatabases CURSOR FOR

SELECT name FROM master..sysdatabases
where name not in (‘master’,’tempdb’, ‘model’, ‘msdb’, ‘distribution’)

— Open Cursor
OPEN UserDatabases

— Define variables needed
DECLARE @DBase NVARCHAR(128)
DECLARE @COMMAND NVARCHAR(128)

— Get First database
FETCH NEXT FROM USerDatabases INTO @DBase

— Process until no more databases
WHILE (@@FETCH_STATUS = 0)
BEGIN

set @command =’master..sp_dboption @dbname=”’ + @dbase +
”’,@optname=”Read ONLY”, @optvalue=”True”’

— Print command to be processed
print @command

— Process Command
exec (@command)

— Get next database
FETCH NEXT FROM UserDatabases INTO @DBase

END

— Close and Deallocate Cursor
CLOSE AllDatabases
DEALLOCATE AllDatabases

5 —-My favorite, lists job calender

USE MSDB

DECLARE

@JOB_ID VARCHAR(200),

@SCHED_ID VARCHAR(200),

@FREQ_TYPE INT,

@FREQ_INTERVAL INT,

@FREQ_SUBDAY_TYPE INT,

@FREQ_SUBDAY_INTERVAL INT,

@FREQ_RELATIVE_INTERVAL INT,

@FREQ_RECURRENCE_FACTOR INT,

@ACTIVE_START_DATE INT,

@SCHEDULE VARCHAR(1000),

@SCHEDULE_DAY VARCHAR(200),

@START_TIME VARCHAR(10),

@END_TIME VARCHAR(10)

CREATE TABLE #SCHEDULES

(JOB_ID VARCHAR(200),

SCHED_ID VARCHAR(200),

JOB_NAME SYSNAME,

[STATUS] INT,

SCHEDULED INT NULL,

schedule VARCHAR(1000) NULL,

FREQ_TYPE INT NULL,

FREQ_INTERVAL INT NULL,

FREQ_SUBDAY_TYPE INT NULL,

FREQ_SUBDAY_INTERVAL INT NULL,

FREQ_RELATIVE_INTERVAL INT NULL,

FREQ_RECURRENCE_FACTOR INT NULL,

ACTIVE_START_DATE INT NULL,

ACTIVE_END_DATE INT NULL,

ACTIVE_START_TIME INT NULL,

ACTIVE_END_TIME INT NULL,

DATE_CREATED DATETIME NULL)

INSERT INTO #SCHEDULES (

job_id,

sched_id ,

job_name ,

[status] ,

Scheduled ,

schedule ,

freq_type,

freq_interval,

freq_subday_type,

freq_subday_interval,

freq_relative_interval,

freq_recurrence_factor,

active_start_date,

active_end_date,

active_start_time,

active_end_time,

date_created)

SELECT

j.job_id,

sched.schedule_id,

j.name ,

j.enabled,

sched.enabled,

NULL,

sched.freq_type,

sched.freq_interval,

sched.freq_subday_type,

sched.freq_subday_interval,

sched.freq_relative_interval,

sched.freq_recurrence_factor,

sched.active_start_date,

sched.active_end_date,

sched.active_start_time,

sched.active_end_time,

j.date_created

FROM sysjobs j

inner join

sysjobschedules s

ON j.job_id=s.job_id

INNER JOIN dbo.sysschedules sched

ON s.schedule_id = sched.schedule_id

WHILE 1=1

BEGIN

SET @SCHEDULE = ”

IF (SELECT COUNT(*) FROM #SCHEDULES WHERE scheduled=1 and schedule is null) = 0

BREAK

ELSE

BEGIN

SELECT

@job_id=job_id,

@sched_id=sched_id,

@freq_type=freq_type,

@Freq_Interval=freq_interval,

@freq_subday_type=freq_subday_type,

@freq_subday_interval=freq_subday_interval,

@freq_relative_interval=freq_relative_interval,

@freq_recurrence_factor=freq_recurrence_factor,

@active_start_date = active_start_date,

@start_time =

CASE

WHEN

LEFT(active_start_time, 2) IN (22, 23) AND len(active_start_time) = 6

THEN

convert(varchar(2), left(active_start_time, 2) – 12)

+ ‘:’ + SUBSTRING(CAST(active_start_time AS CHAR),3, 2) + ‘ P.M’

WHEN

left(active_start_time, 2) = (12) AND len(active_start_time) = 6

THEN

cast(LEFT(active_start_time,2) as char(2))

+ ‘:’ + SUBSTRING(CAST(active_start_time AS CHAR),3, 2) + ‘ P.M.’

WHEN

left(active_start_time, 2) BETWEEN 13 AND 24 AND len(active_start_time) = 6

THEN

convert(varchar(2), left(active_start_time, 2) – 12)

+ ‘:’ + SUBSTRING(CAST(active_start_time AS CHAR),3, 2) + ‘ P.M.’

WHEN

left(active_start_time, 2) IN (10, 11) AND len(active_start_time) = 6

THEN

cast(LEFT(active_start_time,2) as char(2))

+ ‘:’ + SUBSTRING(CAST(active_start_time AS CHAR),3, 2) + ‘ A.M.’

WHEN

active_start_time = 0

THEN

’12:00 A.M.’

WHEN

LEN(active_start_time) = 4

THEN

’12:’ + convert(varchar(2), left(active_start_time, 2) ) + ‘ A.M.’

WHEN

LEN(active_start_time) = 3

THEN

’12:0′ + convert(varchar(2), left(active_start_time, 1) ) + ‘ A.M.’

WHEN

LEN(active_start_time) = 2

THEN

’12:00:’ + convert(varchar(2), left(active_start_time, 2) ) + ‘ A.M.’

WHEN

LEN(active_start_time) = 1

THEN

’12:00:0′ + convert(varchar(2), left(active_start_time, 2) ) + ‘ A.M.’

ELSE

cast(LEFT(active_start_time,1) as char(1))

+ ‘:’ + SUBSTRING(CAST(active_start_time AS CHAR),2, 2) + ‘ A.M.’

END,

@END_TIME= CASE

WHEN

left(active_end_time, 2) IN (22, 23) AND len(active_end_time) = 6

THEN

convert(varchar(2), left(active_end_time, 2) – 12)

+ ‘:’ + SUBSTRING(CAST(active_end_time AS CHAR),3, 2) + ‘ P.M’

WHEN

left(active_end_time, 2) = (12) AND len(active_end_time) = 6

THEN

cast(LEFT(active_end_time,2) as char(2))

+ ‘:’ + SUBSTRING(CAST(active_end_time AS CHAR),3, 2) + ‘ P.M.’

WHEN

left(active_end_time, 2) BETWEEN 13 AND 24 AND len(active_end_time) = 6

THEN

convert(varchar(2), left(active_end_time, 2) – 12)

+ ‘:’ + SUBSTRING(CAST(active_end_time AS CHAR),3, 2) + ‘ P.M.’

WHEN

left(active_end_time, 2) IN (10, 11) AND len(active_end_time) = 6

THEN

cast(LEFT(active_end_time,2) as char(2))

+ ‘:’ + SUBSTRING(CAST(active_end_time AS CHAR),3, 2) + ‘ A.M.’

WHEN

active_end_time = 0

THEN

’12:00 A.M.’

WHEN

LEN(active_end_time) = 4

THEN

’12:’ + convert(varchar(2), left(active_end_time, 2) ) + ‘ A.M.’

WHEN

LEN(active_end_time) = 3

THEN

’12:0′ + convert(varchar(2), left(active_end_time, 1) ) + ‘ A.M.’

WHEN

LEN(active_end_time) = 2

THEN

’12:00:’ + convert(varchar(2), left(active_end_time, 2) ) + ‘ A.M.’

WHEN

LEN(active_end_time) = 1

THEN

’12:00:0′ + convert(varchar(2), left(active_end_time, 2) ) + ‘ A.M.’

ELSE

cast(LEFT(active_end_time,1) as char(1))

+ ‘:’ + SUBSTRING(CAST(active_end_time AS CHAR),2, 2) + ‘ A.M.’

END

FROM #SCHEDULES

WHERE schedule is null

AND scheduled=1

IF EXISTS(SELECT @freq_type WHERE @freq_type in (1,64))

BEGIN

SELECT @SCHEDULE = CASE @freq_type

WHEN 1 THEN ‘Occurs Once, On ‘+cast(@active_start_date as varchar(8))+’, At ‘+@start_time

WHEN 64 THEN ‘Occurs When SQL Server Agent Starts’

END

END

ELSE

BEGIN

IF @freq_type=4

BEGIN

SELECT @SCHEDULE = ‘Occurs Every ‘+cast(@freq_interval as varchar(10))+’ Day(s)’

END

IF @freq_type=8

BEGIN

SELECT @SCHEDULE = ‘Occurs Every ‘+cast(@freq_recurrence_factor as varchar(3))+’ Week(s)’

SELECT @schedule_day=”

IF (SELECT (convert(int,(@freq_interval/1)) % 2)) = 1

select @schedule_day = @schedule_day+’Sun’

IF (SELECT (convert(int,(@freq_interval/2)) % 2)) = 1

select @schedule_day = @schedule_day+’Mon’

IF (SELECT (convert(int,(@freq_interval/4)) % 2)) = 1

select @schedule_day = @schedule_day+’Tue’

IF (SELECT (convert(int,(@freq_interval/8)) % 2)) = 1

select @schedule_day = @schedule_day+’Wed’

IF (SELECT (convert(int,(@freq_interval/16)) % 2)) = 1

select @schedule_day = @schedule_day+’Thu’

IF (SELECT (convert(int,(@freq_interval/32)) % 2)) = 1

select @schedule_day = @schedule_day+’Fri’

IF (SELECT (convert(int,(@freq_interval/64)) % 2)) = 1

select @schedule_day = @schedule_day+’Sat’

SELECT @SCHEDULE = @SCHEDULE+’, On ‘+@schedule_day

END

IF @freq_type=16

BEGIN

SELECT @SCHEDULE = ‘Occurs Every ‘+cast(@freq_recurrence_factor as varchar(3))+’ Month(s) on Day ‘+cast(@freq_interval as varchar(3))+’ of that Month’

END

IF @freq_type=32

BEGIN

SELECT @SCHEDULE = CASE @freq_relative_interval

WHEN 1 THEN ‘First’

WHEN 2 THEN ‘Second’

WHEN 4 THEN ‘Third’

WHEN 8 THEN ‘Fourth’

WHEN 16 THEN ‘Last’

ELSE ‘Not Applicable’

END

SELECT @SCHEDULE =

CASE @freq_interval

WHEN 1 THEN ‘Occurs Every ‘+@SCHEDULE+’ Sunday of the Month’

WHEN 2 THEN ‘Occurs Every ‘+@SCHEDULE+’ Monday of the Month’

WHEN 3 THEN ‘Occurs Every ‘+@SCHEDULE+’ Tueday of the Month’

WHEN 4 THEN ‘Occurs Every ‘+@SCHEDULE+’ Wednesday of the Month’

WHEN 5 THEN ‘Occurs Every ‘+@SCHEDULE+’ Thursday of the Month’

WHEN 6 THEN ‘Occurs Every ‘+@SCHEDULE+’ Friday of the Month’

WHEN 7 THEN ‘Occurs Every ‘+@SCHEDULE+’ Saturday of the Month’

WHEN 8 THEN ‘Occurs Every ‘+@SCHEDULE+’ Day of the Month’

WHEN 9 THEN ‘Occurs Every ‘+@SCHEDULE+’ Weekday of the Month’

WHEN 10 THEN ‘Occurs Every ‘+@SCHEDULE+’ Weekend Day of the Month’

END

END

SELECT @SCHEDULE =

CASE @freq_subday_type

WHEN 1 THEN @SCHEDULE+’, At ‘+@start_time

WHEN 2 THEN @SCHEDULE+’, every ‘+cast(@freq_subday_interval as varchar(3))+’ Second(s) Between ‘+@start_time+’ and ‘+@END_TIME

WHEN 4 THEN @SCHEDULE+’, every ‘+cast(@freq_subday_interval as varchar(3))+’ Minute(s) Between ‘+@start_time+’ and ‘+@END_TIME

WHEN 8 THEN @SCHEDULE+’, every ‘+cast(@freq_subday_interval as varchar(3))+’ Hour(s) Between ‘+@start_time+’ and ‘+@END_TIME

END

END

END

UPDATE #SCHEDULES

SET schedule=@SCHEDULE

WHERE job_id=@job_id

AND sched_id=@sched_Id

END

SELECT job_name ,

[status] = CASE STATUS

WHEN 1 THEN ‘ENABLED’

WHEN 0 THEN ‘DISABLED’

ELSE ‘ ‘

END,

scheduled= case scheduled

when 1 then ‘Yes’

when 0 then ‘No’

else ‘ ‘

end,

schedule as ‘Frequency’ ,

convert(datetime, convert(varchar,active_start_date, 101)) AS schedule_start_date,

convert(datetime, convert(varchar,active_end_date, 101)) AS schedule_end_date,

date_created

FROM #schedules

WHERE scheduled=1

ORDER BY job_name

DROP TABLE #schedules

I hope you all find something useful. And thank you to Allen White for hosting.

SQL Server 2012 – Changes to set up

I plan to write a series of posts while learning more on SQL Server 2012. The changes to set up as I observed while installing SQL Server 2012 RC0 are :

1 Pre requisites include Powershell 2.0 and .NET Framework 3.5
2 If you have Windows 7/Windows Server 8/Office 2010 it expects Service Pack 1 to be installed (does not even proceed until pre requisites if not).

The install is a slipstream process – by that all the necessary pre requisites are part of the media, there is no need to go to separate sites to download/install.
3 There is no reboot required upon install (I only tested it as standalone, with all other programs closed – this may not be true in a cluster install).

4 32 bit install is still supported.
5 Support for Itanium appears to have been removed.

Acknowledgement:

I was inspired to learn more and write by Aaron Bertrand’s presentation on New Features at the PASS conference 2011(http://sqlblog.com/blogs/aaron_bertrand/archive/2011/08/07/sql-server-v-next-denali-changes-to-system-objects-in-ctp3.aspx)

ON SQL Family…

Contributing to Thomas LaRock’s Meme Monday:

I had an interesting experience at the recent SQL Saturday in Louisville. A young man came up to me at lunch and asked me –
Him: ‘So, how long have you been doing this?’
Me: ‘3 years now, this is our third event’
Him:’Wow, great job!’
Me:’Thank you’
Him:’If you don’t mind me asking, is it good money on the side?’
Me:’Sorry?’
Him:’I meant, PASS pays you right, this is a lot of work, organizing this and all this, am guessing organizers and speakers get paid?’
Me:’No we don’t get paid,nobody makes anything off of this’
Him:’Are you serious? These speakers, they all come in for free?’
Me:’Yes, everyone does. Many pay their airfare and accomodation all out of their pocket to come’.
Him:’So you guys all take your personal time and effort for something like this? I have been with MS communities for years, never seen anything like this..Wow, i mean am speechless, wow!, I mean it is a huge effort, how do you find motivation?’
Me: ‘Yes the SQL community is unique, we are family, in more ways than one. We believe in sharing our knowledge and our success and help everyone grow. If you had to organize a family reunion, would you go about doing it or make a huge deal of how much effort it is and how you are not making a dime out of it?’
Him:’Guess I’d do it…I guess you guys are a great family like community, wow, hats off to you all, and thank you. I want to be part of this, I do. Wow, am not over it yet. ‘

I guess that kind of summarizes the SQL family, in more ways than one. We get it done, for the love of it. And we stick together through thick and thin. What more could one ask for?

Event Analysis SQL Saturday 87 – Louisville

We had our 3rd sql saturday at Louisville on 28th October 2011.  It was a huge event with over 230 people attending, 5 tracks and six sessions each. There were many things we learnt out of running an event like this (when i say ‘we’ i am referring to me as key organizer and our volunteering team). Let me start with what went well –

1 282 people registered, 230 showed up. More than double since last year, and very unexpected. Our feedback shows several people impressed with sql saturdays in general is the reason, and that is a great trend.
2 Number of sponsors was much higher, double than normal (although amounts of sponsorship were lower). I still consider this a great trend.
3 Local sponsors (Teknetx and Ebits) were very impressed and want to come back. Building local sponsors is a very difficult task and I consider it very significant that we succeeded this year.
4 Most speakers (other than one or two) seemed happy and wanted to return. This is also a great trend.
5 There was definitely a lot of interest in non technical subjects – toastmasters and women in technology sessions showed good attendance and this is something we want to continue to do.
6 Seating sponsors near lunch area seemed to attract good crowds to them, this is also something we want to continue to do.
7 Buffet lunch went very smoothly and was a great idea compared to boxed lunches.
8 Pre conference with Kevin Kline – had a great turnout – again much higher than expected and was very smooth. Most people including volunteers enjoyed it greatly. We definitely want to do more of these,  perhaps with speakers who are close to town and can get in easily.
10 I got some great feedback on quality of speaker shirts, some internal signage especially posters, and printed schedule book. We will continue doing them, although the printed schedule would depend on the budget.
11 Costumed volunteers and speakers seemed to go down very well. Even met an attendee at a crowded Trader Joe’s today who asked me if I was the ‘lady in the pink hat’ at sql saturday, and complimented us for turning out in colorful costumes. I am definitely going to save that hat , perhaps wear it next time around also 🙂 In short this means creativity is appreciated and we will definitely look at this further.
12 Timing was good in terms of weather and other logistics, not to mention creativity added on by Halloween. This looks like a good time to have the event every year.

What did not go well – am afraid this was a little more than what we expected this year. There were two main reasons – one of them was that we needed lot more volunteers than what we had for an event of this size. Finding committed volunteers is a very hard task. Our existing volunteers were stretched to the bone,and last minute efforts at finding more people did not succeed. Most people on the sign up list did not respond to emails and we only had those who had been with us through the event planning. Second, we really did not expect double the number of people. This is very hard to plan as around 60% of registrations happen in the last month or so, when we are set in terms of planning location, budget and volunteers. We assumed a 50% or so increase, but not this much and this is what caught us off guard in many respects.

1 Breakfast – any event organizer’s nightmare come true, happened to us. The caterer was known for their reputation and quality, but just happened that they had a staff turnover and the new team had us as their #1 client. So breakfast showed up 40 minutes late – after several desperate calls. The driver had lost his way and gone to the other side of town. When it arrived the coffee was cold, there was no cream, bagels had no sides. We asked for a second delivery of coffee, and it was delivered again, but with no cream! (talk of software programs with bugs, looks like people have them too). Anyway, the caterer and several people on their side called repeatedly to apologize.

2 Registration – our volunteers were caught up in sorting raffle tickets which apparently sorted wrongly by the print shop on a batch basis instead of a person basis. This made it very hard to hand over a batch of tickets to the right attendee. Lots of people also showed up earlier than opening time, and with no coffee around it made it seem really long for them.

3 Lunch was delivered early – again this was an issue arising due to some logistics. There was a tailgating party/soccer match in the vicinity and we were warned of traffic holdups in the area. Despite checking with several people we were unable to get a good idea of how bad this situation was and how much we needed to plan around it. So we decided to play it safe and ask the caterer to deliver early. The caterer messed up breakfast and was eager to make us happy, he delivered more than an hour early. This left several people displeased although there was plenty of food to go around.

3 Session scheduling – this was a blunder on our side. We used the default template PASS had which had no breaks between sessions. We also had several sessions that seemed too good and limited rooms to work with so we went with 45 minutes per session (which is by the way how we do it at user groups). This was definitely a bad idea, and a couple of speakers were really put off. We will have to work with lesser sessions per track but more tracks/more rooms next time.

4 Location was crowded, registration area small and so on – This was some of the feedback we received from attendees. Again the turnout was unexpected and the location was clearly not built to handle such a crowd. We will definitely look for bigger locations next time.

5 Post event social was not on premises – One attendee suggested a party on premises including an open bar 🙂 I guess with the growing number of well funded sql saturdays lot of people tend to forget that some events may not have funds, and secondly our event was on school premises, there is no chance of having an open bar there even if we could have afforded it. The problem with post events generally is that again we don’t know how many people are going to show up. We planned one the first year and there were only about 20 people. That number is not enough to book a restaurant or any place, especially around halloween when there is a lot of demand. The second issue we have is that volunteers were extremely tired and none of us had any energy to do a social. We will address both issues with next event.

6 Raffle drawing – This was scheduled for 5 30 pm. By 4.45 or so several vendors started to pack up, did their own drawings and gave me the gift with winner’s name and left. I was not sure if waiting until 5.30 pm was a great idea so we had it early, at 5 pm. This left out several attendees who were in the other building attending a session that went over a little. This is an issue we plan to address both with vendors and advisors of sql saturday. There was also some feedback regarding ‘more gifts and prizes’ – again I believe this arises out of some events having a lot of funding to play with. We had three Ipads, one XBox Kinect and several small prizes. It was good for an event of this size, and don’t plan to address this any further.

Takeaways:
1 Find a bigger building and have all sessions in the building. Have more tracks and less sessions with 15 minute gap between each session.
2 Divide breakfast between coffee and food, again I may be paranoid here but I think we should make arrangements for that java to arrive and be ready before people do.
3 Get more student type volunteers or those who have no interest in sessions to sit in all day at registration and at food table.
4 I hate to say this but I want to – that is not pick speakers who are hyper critical or not understanding of effort that goes into organizing a free event. Granted some things did not work as expected but to remember these events are free and done with huge amounts of effort.Atleast try to talk to organizers cordially, offer some feedback in encouraging ways, not just dump us and take a high handed stance. If you are so demanding our response would be ‘sorry, we want to work with friendly people next time’ – there is no shortage of them in the sql community.
5 Do more precons – particularly with speakers who are close to our area and do not have huge demands on number of attendees.
6 Work harder on hosting a good post social.

SQL Saturdays are a huge amount of work. But to date, i have not met one volunteer who regretted doing it. Most of us feel empowered in fact to do more and better. That is in itself proof of community and learning. So here is a huge thank you to all of you who supported us and worked with us, and hope to see you again until next year!!