Author: way0utwest

  • Microsoft and R

    Microsoft purchased Revolution Analytics recently, a commercial company that works with the R programming language. This seems to be a decision to improve the analytics and analysis offerings from Microsoft. I’ve heard this will be incorporated into their Machine Learning offering, but I wouldn’t be surprised to see some basic R support in SQL Server at some point. If you’re not familiar with R, we’ve got a basic piece at SQLServerCentral on it.

    Microsoft has made lots of acquisitions before, and while there’s some question of whether Microsoft can make R easy to use, I think they can. Years ago, Microsoft bought Proclarity, a company that had some BI type products. Did they succeed with that acquisition? I think they did. A number of the technologies likely made their way into PowerPivot and Power View even though the Proclarity products have somewhat disappeared, being incorporated into other products.

    The R language and environment is complex, and I’m not sure how many database developers or DBAs want to become experts. However I do think that it could be possible to make the language easier, perhaps by building functions into SQL Server that help with the data analysis and computational features, and adding extensions in ADO.NET or other client libraries that might support easier rendering of visualizations.

    We have lots of tools to help here already, with PowerPivot and other related Excel add-ins, and I suspect that any offerings here will overlap with those products, but allow Microsoft to woo an even wider audience of data professionals.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 1.9MB) podcast or subscribe to the feed at iTunes and LibSyn.

  • Measuring My Career

    I’m going to do a shorter editorial on this, but really I think this deserves more treatment here.

    I saw Brent Ozar write a post on measuring your career. In it, he talks about the fact that many people measure their career as a function of their salary. He points out that that’s a poor measure, as it’s really based on something in the past, not the current position or situation in which we are engaged.

    I agree, plus I think salary is a poor way to measure success. It’s a crude, gross way to compare the value of one job to another, based on someone else’s view of your job. Your employer decides what constitutes a fair salary, which may have nothing to do with you, your work, the responsibilities, or the total work you accomplish.

    Boiling It Down

    Speedometer
    Pegging the needle

    I’ve been asked many questions in my life, often something like “how would you rate xx?” or “on a scale of 1-10, what do you think of yy?”

    In all those cases, I’ve struggled to do much more than peg the needle in my rating. It’s all the way left, all the way right, or dead center.

    The reality is that so much of our views of anything, whether it’s our career, our car, our laptop, or anything else can’t be boiled down to a single number. It’s silly to try, and I’ve given up. I’m not going to rate things along one axis when there are many ways to view anything, along different sets of criteria.

    It’s one reason I really have started to discard all speaking feedback other than comments. The 1-5 scale means nothing to me. If you can’t express a positive or negative criticism or praise to me, then I don’t gain anything from the evaluation.

    My Career

    My career has been great. Not all an upward rise, nor all an unbroken series of successes. I’ve had setbacks, and at times, I’m a little disconcerted by the number of jobs I’ve had. However overall, my career is a success.

    Why?

    For one thing, I’ve been able to make a difference in many jobs. I’ve written software, a report, documentation, or produced something that was useful to others. They’ve told me it saved time, it saved money, or just that they appreciated it. That’s a success.

    My income has gone up over the years, but it’s also gone down. If I were to look at my salary, it has a few nice dips in it. However the important thing is that at most every stage, it’s been enough money to take care of the needs of my family. Sometimes we’ve also needed my wife’s income, but that’s OK. The reality is that my salary doesn’t stand alone. It goes hand in hand with my wife’s and together the numbers have to make sense. I can make less if she makes more, or vice versa.

    Or we fix our budget. That’s an area that some people don’t consider. If I can change my budget, take a lower salary at a position I like better for some reason, then it’s still a growth in my career.

    I’ve also thought that my career flexed and changed to fit my life. When my kids were younger, I really valued having a job that kept me at home and limited travel. My current position at Red Gate wouldn’t have been a good fit then, but it is now, with teenagers and adult-aged children.

    What’s Important?

    Tractor with hay
    Every job’s a job at some point.

    If I were to measure my career right now, in the context of my current situation at home and my position with Red Gate, it’s the best job I’ve ever had and it’s a huge success as I view it. It’s not perfect, but it’s like my tractor.

    When I first got a tractor for the ranch, I thought it was so cool. It’s a big, powerful piece of equipment and it gives you a sense of power to drive it around. I can move snow, pick up huge objects like hay bales that I could never move alone, and drill holes in the ground with an ease I never thought possible. Driving a tractor around to plow snow or cut grass is always cool.

    For 15 minutes. Sometimes 5 minutes. Then it’s work. Often it’s tedious or really annoying to do something over and over. However I’m always thrilled when I first get going on the tractor.

    I have this view of jobs. No matter how amazing the position is, whether it’s rock star, professional athlete, journalist, or DBA, at some point you’re going to have to do something you don’t enjoy or want to do. You’re going to have tedious moments. You’re going to get bored.

    Hopefully you get energized with the next project, day, or city you tackle next in your job.

    My job is hard. The travel wears me out at times. Video calls can be maddening when people are late, or they don’t speak into the microphone, or any of the things Scott Hanselman ranted about. The tedious nature of administering the site, or editing poorly written articles, and more can wear on me. The stress of putting out daily information tightens the muscles in my neck and fills my stomach with butterflies at times.

    I put up with those things because I love writing, speaking, and teaching people about SQL Server. I like learning new things, I like working for a company that values me and gives me opportunities. I like working from home on a flexible schedule. I like the challenge of trying to help the community and improving other’s careers and success at work.

    I guess that you have to start rating the importance of things in your career in the ways that are important to you. What matters in your life? When you find the position meets more of your needs than it doesn’t, when you have more positives than negatives, when you have more good days than bad, I think you’re succeeding.

    Good luck, remember you get one life to live, so take advantage of it while you can, and always, always, work to live rather than living to work.

  • ALTER SCHEMA TO ADD PERMISSIONS

    I’m sure some of you have wanted to do this:

    ALTER SCHEMA Steve AUTHORIZATION Steve

    You realize this doesn’t work, and you can’t grant the user Steve, rights to his schema after it’s created. You can do this:

    CREATE SCHEMA Steve Authorization Steve

    UPDATE: Someone pointed out this works after the fact:

    ALTER AUTHORIZATION ON SCHEMA::Steve TO Steve

    But not alter it. Strange and annoying. In my last post, I showed dropping and recreating the schema. That works well if you are beginning development, but not when you’re in the middle.

    Let’s make this less confusing and see how we actually allow a developer to access a schema to create procedures (or other objects) when the schema exists.

    First, let’s assume we want a developer, Steve, to be able to create procedures in the ETL schema. We have these conditions:

    • The ETL schema exists
    • The ETL schema is owned by another developer.
    • The login and user, Steve, exists in this database with no permissions.

    I want to now allow Steve to build the procedure ETL.MyProc.

    Grant Permissions

    The first thing I do is grant create procedure permissions to Steve.

    CREATE LOGIN steve WITH PASSWORD = ‘Test’;
    GO
    USE Sandbox
    GO
    CREATE USER Steve FOR LOGIN Steve
    GO
    GRANT CREATE PROCEDURE to Steve;

    GO

    With this done, now let’s set up our schema.

    CREATE SCHEMA ETL
    GO

    There are no default permissions, so the user Steve cannot create ETL.MyProc right now. How do we fix this?

    The trick here is that I need to allow Steve to ALTER the schema. I can do this by using this statement.

    GRANT ALTER ON SCHEMA::ETL TO Steve;
    GO

    I could do other things. I could grant CONTROL. to Steve instead, but I might not want to do that. That gives Steve the ability to actually drop the schema, which probably isn’t want. It’s certainly not the “least permissions” to let the developer create objects in a schema.

  • Data Generator – Limiting Values

    This is a series on SQL Data Generator, covering some interesting scenarios I’ve run into. If you’ve never tried it, SQL Data Generator is a part of the SQL Toolbelt. Give it a try today with an evaluation today.

    I needed to generate some data for some development work on the SSC database. No, I’m not allowed to change code directly, but I was looking to send some changes to the development team, already done, and then hopefully just have them test and deploy it.

    In my case, to avoid exposing any real data in case of issues, I downloaded the schema only to my laptop. The I created a database with all the objects. One of my first areas of work was on the points and scoring systems, but to do that, I needed points.

    sql-data-generator-150

    I fired up my copy of Data Generator, let it detect the objects, and pre-populate the fields and clicked “Generate Data”. That worked well, and I had a bunch of data in my system.

    pointsgenerator_c

    My first area of work was to rewrite some procedures that perform calculation. I did that, ran a simple SUM, and got this:

    Msg 220, Level 16, State 2, Line 3
    Arithmetic overflow error for data type int

    Not what I expected. I just generated some data and ran a sum. What could be the issue?

    It turns out that the default settings for integer columns are shown here:

    pointsgenerator_b

    That’s great if you want a random distribution, but it’s not so good in this case. The points values I want to store for each row should be fro 1 to 7, and randomly distributed. I’d actually like them to be weighted towards 1 and 2, but for this project, it doesn’t matter.

    I decided to fix things by first deleting all the points data. Once this was done, I could then select the table on the left, and select the column.

    pointsgenerator_d

    This changes the right panel to the specific settings for this column. I changed the values, as you can see here, to be more in line with my needs. Only values from 0 to 7 are included.

    pointsgenerator_e

    I could actually use different settings for different columns. For example, for the PointsCategory column, I used these settings, from 1 to 1,000.

    pointsgenerator_f

    With these new settings, I generated new data for this table, and then my aggregate calculations worked.

    Data generation is a very handy thing to have, especially in development environments where you don’t want live data. In my case, while I think my systems are fairly safe, I’d hate to lose my laptop, with a copy of the SQLServerCentral database and a million emails that people might not want shared.