Tag: T-SQL Tuesday

  • T-SQL Tuesday #31 – Logging

    TSQL2sDay150x150It’s T-SQL Tuesday time again, and this month Aaron Nelson (blog | @sqlvariant) is hosting. The topic is logging, and if you’re like to participate, read Aaron’s post and learn the rules. We do this on the second Tuesday of every month.

    If you’d like to host, contact Adam Machanic. It’s easy to do. Get on the schedule, pick a topic, and then write a post.

    A list of previous posts is here,

    Logging

    I’ve found documentation of events to be one of the most important things I can do in my career. Finding out what happened, what changed, or what I did has been important many times, and often helped me come through difficult situations.

    Logging is the automated version of documentation. All kinds of applications, including SQL Server, produce logs of the various activity on the system. In SQL Server, we are moving to an eventing system, and if you haven’t looked at Extended Events, you should.

    One of the times when I found logging to be lacking was in a startup I worked at a decade ago. We had a number of developers that were working on various development servers. They had full rights, and they were allowed to build their own objects. That was a little concern to a controlling DBA like me, but I allowed it since they often wanted new objects quickly, and if I allowed them to write their own, they’d use stored procedures.

    A good compromise, if you ask me.

    However in the hectic pace of development, I found that the developers didn’t often keep good notes about what was being built for which features and functions. Since we had to produce a build script fairly quickly every Monday in order to update our QA systems, we would find that developers invariably would forget objects and we would not have a well tested QA script on Monday afternoon.

    I decided that we needed to better log the changes on our development server. I didn’t care about every change, especially intermediate changes to objects, but I did care about the gross changes made each day.

    This was in the SQL Server 2000 days, with limited tracking of changes outside of SQL Trace. Since I had no desire to move through lots of trace files, even in an automated fashion, I decided on a much simpler method.

    In sysobjects (now sys.objects), there was a crdate field, which tells you when the object was created. However that doesn’t change if an ALTER TABLE is run (or any other ALTER). That stumped me briefly, but I decided to search further.

    I found that there was a schema_ver field, which is incremented every time the object is changed. Since the majority of our developer changes were ALTERs, I could track the version number and then compare this each day. I tested this out, and it worked well.

    The outline of the solution is that I grabbed a copy of the sysobjects table every day and stored it in a temporary table. I then used a left join to compare this with the previous values stored in a table I’d created to store the data. When I found differences, I logged them in a table, along with the date, and sent myself an email. I would then overwrite the stored version of the objects with the version from the temp table, giving me a baseline for the next execution.

    At the end of the week, I’d have an aggregate list of all objects changed, which I could then compare against our build script.

    At the time we were in an agile environment, releasing new code every Wednesday, and operating on very short timelines. The logging I did cut down on mistakes and allowed us to have a smooth release process that functioned for over 18 months, with code releases nearly every Wednesday outside of holidays.

  • T-SQL Tuesday #30 – Ethics

    TSQL2sDay150x150This month the topic is hosted by Chris Shaw, and his topic is ethics.

    The blog party is the second Tuesday of each month. There is a theme and it is hosted by a different blogger every month. I’ve got a complete list of topics on my blog if you want to read about the past entries.

    It was started by Adam Machanic and if you want to host one, let him know. It can be fun, though a little busy as you compile a summary of the posts from the month.

    Ethics

    I thought this was a great topic, and I’ve actually written on it before. Chris asks a few questions about ethics and they are good ones. I’d like to think that most people have a good code of ethics, but I also think many people haven’t really thought through what their ethics are on this situation. You should do your job, and do what you’re told, but I think breaking the law, or performing an action that violates your moral principles is a no-no.

    However when you get into more subtle issues, like the one Chris talks about with regard to security, what do you do?

    Overall you have to follow your moral compass and use The Test.

    • If you have any doubt about what you’ve been asked to do, seek a second opinion, and get a confirmation from your boss (or their boss) in writing.
    • If you are sure it’s wrong, don’t do it, give you reasons, and let them get someone else to do it.
    • If it’s illegal, you should report it.

    I know sometimes this puts you in a bad situation, and you may fear for your job. That’s natural, and understandable, especially if you are the sole breadwinner for your family.

    However you also have to live with your actions, and they reflect on your soul daily. I would ask that you make the right decision, even when it’s not the most popular, profitable, or palatable one.

  • T-SQL Tuesday #28 – Jack of all Trades, Master of None

    tsqltuesdayIt’s that time of the month again, T-SQL Tuesday Tuesday. This month Argenis Fernandez, MCM, and big round SQL teddy-bear is hosting. His topic is Jack of All Trades, Master of None.

    The second Tuesday of every month is when the blog party takes off. If you want to participate, read Argenis’ post and write your own entry. If you want to host, contact Adam Machanic.

    Jack of All Trades, Master of None

    After my third year of college, I went to work at a new hotel in Virginia Beach. I hadn’t had much experience in the restaurant industry, other than cooking one semester at college, so they hired me to be a busboy and room service waiter. I opened the hotel working in the café, but the slow start caused some people to quit. When a waiter didn’t show up one day, I volunteered, got a chance, and moved up in the world. When a bartender didn’t show up one afternoon, I volunteered, and had a new gig for the rest of the summer.

    It’s been a mantra for me for the most part in my career. I like challenges, I like new things, and I’m not afraid to tackle much. The same way I moved up in the restaurant business to new (and better paying) jobs worked in technology. However the “jack of all trades” philosophy hasn’t been just about getting new jobs, but also being better at my main job.

    At more than a few companies, I’ve been happy to fill in for the network person, the sysadmin, the Exchange manager, the developer, doing my best to fix something or improve it. As I’ve been a DBA, I’ve worked on PHP, ASP, HTML, XML, Cisco IOS, configured T-1 lines, changed batteries in UPSes, and more. Those skills have helped me to understand how things are put together, and enabled me to solve more than a few complex problems, in complex architectures, because I could truly see the forest. Even if I didn’t understand how everything worked, I knew how lots of parts were supposed to work, and how they were plugged together.

    Even today in SQL Server, I write about all sorts of topics, and review pieces on all aspects of the SQL Server platform. I don’t know how to configure them all as an expert, but I know a lot about how most of the platform works, even if I don’t know all the details. Sometimes that’s enough to get me by.

    It’s not all perfect, and I don’t think being Jack is better than being a master. There are more jobs for the “Jacks” of the world, but the pay tends to be lower. Masters make more, but have fewer opportunities, and fewer places they might get to live/work at any point in time. There’s a (I think) higher level of satisfaction from being a master in some area of your field, and I can appreciate that. I’ll also say that most of the “masters” I know that are fairly specialized have this innate motivation to learn more about their topic, which bleeds off into other sections of their field, making them knowledgeable in a “Jack” way on other parts of their industry.

    In the end, I think it’s fine to be a Jack or a master, just be true to yourself. Do the things that you enjoy, and if that’s one or the other, you should have a great career.

  • The T-SQL Tuesday #027 Roundup

    UPDATE: I found a few more posts, and have added them to the round up. Trackbacks didn’t work for some reason.

    I didn’t have quite the level of participation for T-SQL Tuesday #027 that I would have liked. I understand it was a holiday, and many people might have been otherwise occupied (a good thing), and there’s less work for my round up (a good thing), but less information out there (a bad thing). Perhaps it wasn’t a great topic, but in any case, here’s the roundup.

    In the early hours of the day, Rob Farley in Australia gave is a short preview of Big Data coming in 24 hours of PASS.

    Right behind Rob, Pinal Dave in India gave a simple explanation of Big Data that I thought made it easy to understand some of the concepts behind how Big Data and SQL Server fit together.

    Sebastian Meine wrote an interesting piece on purging data, and how large data manipulation operations can benefit from indexing.

    The SQL Philosopher talks about some of the challenges of rapidly growing data in his environment.

    Vinod Kumar has a nice summary of what the challenges of Big Data in general can be.

    Bob Pusateri has a post on why he loves Big Data. I agree with him that Big Data gives the DBA a chance to shine, but also a chance for lots of headaches. You have to decide how you feel about that.

    Mike Walsh has a post on what he’s doing with Big Data, and Hadoop, with a client of his. An interesting read on the application of large data sets.