Author: way0utwest

  • Winding Down

    I’m trying to finish up the last few things here at work before taking the weekend off. I scheduled off the next two days and plan on tiling my bathroom. Tia says it’s not really time off, but it’s a good project, it’s mindless (relatively), I’ve been wanting to do it, and I plan on leaving the computer alone. I might still be tweeting from the iPhone, but no work on SQLServerCentral.

    So I’ve scheduled out the next two newsletters, I’m editing Monday’s podcast and uploading that, and will schedule that newsletter tonight. Then I’ll be about done for 4 days.

    Looking forward to unwinding a bit. Now I need to remember to pick up some more beer tonight 🙂

  • Heading Down to the Basement

    I’m taking the next two days off, heading down into the basement for a four day weekend. Nothing particular going on, just a little stressed with life. Between work here and a busy life with kids, I realized a few weeks ago that I was feeling stressed. So I decided to take a few days off. I would have done it then, but it’s a little hard at times to get coverage for the site here on short notice.

    That’s changing, and I realized it’s an issue. I’ve been working with a few guest writers to cover the editorial content, and I’m trying hard to keep a 2-3 week schedule on content so that if I need to take a day off, I can. Hopefully it will be easier to do this moving forward.

    I have no great plans. My wife will be gone Friday for some horse thing (and all weekend), kids in school, so I think I’ll actually tackle a project around the house; something non-technology related around the house.

    After we bought our house, I started working on various things, but one project I was proud of was tiling our bathrooms. We have 4 in the house, and after an accident our first week in the house, we knew that the carpet which had been put in there by the previous owners wouldn’t do. I tiled my daughter’s bathroom. It was the smallest one, it worked well, and my wife was pleased. So I then did the boys’ bathroom, and while it was a little more involved, it worked. A few months later I tackled the guest bathroom, and things were looking good.

    I never got around to the master bath, mostly because it’s a big project, and the kids tend to use our shower/bath regularly. That’s changing now with kids getting older, and with my wife gone, next weekend is a good time to lay tile. It’s a messy job, so don’t expect me to respond to many emails or notes over the weekend. I’ll be up to my elbows in ceramic chips and dust.

    See you Monday!

  • Temp tables and scope

    I saw a question recently about temp tables and when I was answering it, I learned something. With this code:

    create table MyTable (ID int)

    go

    create proc MyProc

       @id int

    as

      create table #test (id int)

      insert MyTable select @id

      insert #test select @id

    return

    go

    exec MyProc 2

    go

    select * from #test

    go

    drop table MyTable

    drop procedure MyProc

    Do you expect the SELECT to return anything? Will the temp table be in scope? It’s an interesting question, and I would hope most of you would know the answer if you’re coding in T-SQL. What about this code?

    create table MyTable (id int)

    go

    Create Table #Test (id int)

    go

    create proc MyProc

       @id int

    as

      insert MyTable select @id

      insert #test select @id

    return

    go

    exec MyProc 2

    go

    select * from #test

    go

    drop table MyTable

    drop procedure MyProc

    Does the SELECT return data? The answer to the first is "no" and the second "yes". The reason is scope. While a local temp table (single #) is visible to your entire session, which means multiple statements, it isn’t always in scope.

    I had to think back to basic computer science and stacks as to how this works. In the first set of code, the variables and temp table that are used in the procedure are created and put on the stack of data while the procedure is being executed. That means that as long as the procedure is being executed, those items can be accessed.

    Once the procedure ends, they are popped of the stack and discarded. So that the "select * from #test" returns an error.

    In the second set of code, the temp table is put on the stack when it’s created. When the procedure is executed, it gets more values on the stack for it’s variable, but the temp table is still on the stack. When the procedure ends, @id is lost, but the temp table remains.

    The values aren’t really placed on the memory stack locations. Rather their references are, with the temp table living in tempdb (or memory) and the variable in memory as well. The stack used for tracking scope is lots of complicated, I’m sure, than what we dealt with in basic Pascal and C back in high school or college, but the theory remains the same.

    You have to know your scoping rules when programming, or you might easily get into trouble and spend a lot of time debugging things that should be simple to understand.

  • Storing the Sun’s Energy – Solar Power

    I stumbled on this article about a spin-off from MIT using solar power to create hydrogen. I think it’s a great idea, one that I’d like to have working in my house, but it’s not as simple as having a storage tank and a solar panel.

    To me this requires some fundamental changes in how we power devices. Whether it’s a car, a generator, or my house, I need an easy way to not only produce the power and store it, in this case using hydrogen, but then easily consume it as well.

    In a house that means that I need some power generator that can automatically take me off the grid, or reduce my usage, and use this power in my house. In a car, this means a way to get from this storage mechanism into my car.

    I’m all for this idea, and I’d really like to get something like this working. I could envision this as a way to power our barn, or heat water, but automatically burning off the hydrogen to produce power or heat (or both) and then using that in standard appliances.

    I envision some 2 tank system, one that is getting filled, and one that’s being used. Some type of small controller that determines which is which, manages the load, etc. This could work, but I think it means a re-engineering of how we consume power in a residential situation.