SQL String Parsing

by Web Master 30. July 2015 12:10

I found a slick way to parse a string in SQL at link.  It utilizes the XML features offered by SQL Server to break down the string into components.  Here is the code sample from the link:

declare @s varchar(max) = 'I=940;A=29.5;D=20090901|I=941;A=62.54;D=20090910|I=942;A=58.99;D=20091005|I=954;A=93.45;D=20091201|I=944;A=96.76;D=20091101|I=946;A=52.5;D=20091101|I=943;A=28.32;D=20091101|I=945;A=52.5;D=20091101|I=955;A=79.81;D=20091201|I=950;A=25.2;D=20091124|I=948;A=31.86;D=20091110|I=949;A=28.32;D=20091120|I=947;A=25.2;D=20091109|I=951;A=242.54;D=20091124|I=952;A=28.32;D=20091129|I=956;A=38.94;D=20091210|I=957;A=107.39;D=20091215|I=958;A=32.55;D=20091228|I=959;A=27.3;D=20091228|I=960;A=24.79;D=20091230|I=1117;A=28.32;D=20100131|I=1115;A=272.58;D=20100131|I=1116;A=159.6;D=20100209'
declare @xml xml

select @xml = '<item><value>'+replace(replace(@s, ';','</value><value>'), '|','</value></item><item><value>')+'</value></item>'

select N.value('substring(value[1],3)', 'int') as Invoice,
       N.value('substring(value[2],3)', 'money') as Amount,
       N.value('substring(value[3],3)', 'date') as [Date]
from @xml.nodes('item') as T(N)

This example produces a table with each item's invoice, amount and date.

Tags: , ,


Mother's Hibiscus

by Web Master 22. July 2015 10:14

My mother grows the most beautiful, large hibiscus flowers in her yard. They bloom only in the summer as the winter is too cold here.



Hibiscus Flower

Tags: , ,


Camping in Colorado

by Web Master 19. July 2015 23:28

This year (2015) was my first camping excursion in the Rocky Mountains in Colorado. Highlights of this trip included driving over Independence Pass and a visit from a ghost bear. Yes, a ghost bear! Read on to find out more....

Independence Pass

For summer vacation, we decided to visit my sister in Aspen. There are many outdoor activities in the area. One that we decided to explore is the exciting drive over Independance Pass, a narrow road with steep dropoffs, hairpin turns and an elevation of 12,095 feet.  You can read about the pass on Wikipidia. The scenery is spectacular. There are several campgrounds, hiking trails and the ghost town of Independence (info).

Ghost town of Independence

View from the summit

Weller Campground

While driving through Independence Pass we camped in Weller Campground (info). It's a nice campground, though the door to the toilet didn't have a lock so we had to stand guard for each other. Weather was partly cloudy and not too cold considering the elevation. There is an easy hike to Weller Lake across the road (info).


Camping in Weller Campground

Wildlife in the campground

Weller Lake

Ghost Bear

Most of the time you hear about ghost stories told to frighten your fellow campers around a camp fire. These are fanciful, made up stories to add excitement to the camping trip.  What I am about to tell you is a real ghost story. No one told it to me. It really happened to me.

During the night while camping in the back of the truck in Weller Campground we woke up to the sounds of scratching.

<scratch> <scratch> <scratch>

It sounded like an animal scratching at the passenger door. I thought it must be a bear trying to get into the cab of the truck.  Perhaps some food left in the truck had attracted it.


I was hesitant about leaving the safety of the back of the truck to confront the animal.  Looking out through the windows with a flashlight was inefective due to the reflections of the window. Perhaps it could be scared off.  I used the truck remote to unlock/lock the doors. This had the effect of turning on the headlights.  The sound stopped. We waited, listening for sounds of movement outside the truck. Moments passed.


The sound of scratching returned. The bear was still trying to get into the truck. I had thoughts of the animal damaging the truck in its efforts to gain access. How were we going to scare it away. I still couldn't see anything through the window.


Was that a jostle of the truck as the animal tried harder to gain access? I must find a way to scare it so that it would leave the truck alone. I reached for the remote and pressed the button to start the engine. The truck started and the headlights turned on. The sound of the scratching stopped, but I couldn't see anything outside. I waited a minute before shutting off the engine. Was the bear gone?  We waited.


Oh no! The bear was still outside! What was it going to take to convince the bear to leave us alone?  I couldn't see anything outside. The other people camping were all asleep. I needed to stop the bear before it damaged the truck. I decided that I should go outside and take a look to see exactly what was happening. I unzipped the tent used to extend the bed of the truck and poked my head outside with the flashlight. I shined the light around to see if anything was behind the truck.  I couldn't see anything out of the ordinary, though the scratching had stopped. I tried looking to the side of the truck, but couldn't do so without fully exiting the back of the truck.  I slowly stepped outside and peeked around the corner. Nothing. I shone the light under the truck. Nothing. I looked at the other side of the truck and in the bushes. Again nothing. What had been making the noise? It wasn't windy and there were no trees or bushes rubbing against the truck. I looked at the door expecting to see paw prints, but saw nothing.

I climbed back into the bed of the truck and zipped up the back. There was no scratching while I investigated outside. Perhaps the animal had been scrared off when I exited the vehicle? I got back under the blankets hoping the matter was at an end.


The scratching had returned! We decided to ignore the scratching. It took a while to go back to sleep with scratching noises outside, but there was nothing else we could do. How do you stop a ghost bear? At least it wasn't doing any damage to the truck. Maybe if it was ignored it would go on its way.

I awoke in the morning to the noises of other campers breaking camp. No more scratches could be heard. The ghost bear had moved on.

Dumont Lake Campground

We also camped at Dumont Lake Campground (info) near Steamboat Springs. It is a very nice campground with great views of meadows, mountains, trees and wildflowers. Dumont Lake is close by, but not visible from the campground.


Camping in Dumont Lake Campground

Trail near Dumont Lake Campground



Tags: , , , , , , ,

Recreation | Camping

Religious Freedom

by Web Master 4. July 2015 23:36

With marriage equality becoming the law of the land there have been several instances where business and government employees, such as county clerks, bakers and florists, have refused services to same-sex couples using the excuse that doing so violates their religious freedom. They do not want to participate in a same-sex wedding. It is illegal to deny services based on certain traits of people requesting the service, such as religion, sex, race and, in some States, sexual orientation. The courts are finding businesses that deny services to same-sex couples for their weddings are in violation of these equal protection laws. Are the business owners and government employees being denied their religious freedom by being forced to accomodate marriages between people of the same sex?  I say no, they are not being denied their religious freedom. Let me share my reasoning.

The business and government employees provide services to the general public also known as a public accomodation.  The service provided may include baking a wedding cake in the case of a baker or issuing a marriage certificate for a county clerk. The complaint has been that the employee doesn't want to participate in a same-sex wedding and providing the service makes them a participant. This is nonsense. The service provider is hired to do a service, not to become a participant. How many brides and grooms thank their florist for "participating" in the wedding? None! They may thank them for the flowers, but don't consider them active participants. To think this is utter nonsense.

Some people argue that to provide a wedding cake or flowers to a same-sex marriage is asking the business to provide a new service that they don't provide.  Comparisons are made to asking a Muslim restaurant to provide bacon when that isn't already on the menu.  This argument is also nonsense. There is no physical difference between a cake made for a wedding between a same sex couple and that of an opposite sex couple. The product is EXACTLY the same physically. If the baker was asked to change the cake, such as putting a distasteful message on it, then that is a service they don't provide to anyone, gay or straight, and need not make that change. However, the people denying services are not doing so because of any physical change to the service. They are just flat out denying a product they would serve to an opposite sex couple to the same sex couple.

From a religious standpoint, why is it that a service provided to countless opposite sex couples suddenly become a sin when given to same sex couples? You aren't sinning because of what other people are doing with your product. The employee is not being asked to marry someone of the same sex. They are only expected to provide the SAME service to everyone EQUALLY. Actions, such as baking a cake, don't become sinful because of what your customer does with the cake!



Tags: ,

Politics | Religion

Marriage Equality

by Web Master 30. June 2015 12:26


I have long been a supporter of equal rights and marriage equality. I am in a same sex marriage, so that should not surprise anyone. I was overjoyed when the Supreme Court of the United States (SCOTUS) decided on June 26, 2015 in a 5-4 vote in favor of marriage equality (see Obergefell v. Hodges).  This decision found that State bans against same-sex marriage and the failure to recognize those marriages performed in a different State were unconstitutional under the Fourteenth Amendment of the Constitution of the United States (COTUS).


The White House was lit in rainbow colors to celebrate the decision

Not everyone has been happy with this decision.  Here are some of the concerns and my response to them:

Concern: Churches will now be forced to marry same-sex couples.

Some churches do marry same-sex couples, but that is the decision of the church leaders, not of the U.S. government. Religious beliefs are protected by the first amendment of the COTUS and this decision does not change that. Churches can continue to decline marriage services to interracial couples, blacks, whites, same-sex couples or anybody else they choose to reject. For example, a church denied marriage to a black couple in Mississippi (link).  Race has long been held as a protected class, but the church was within its rights to deny them.

Concern: The SCOTUS overstepped its bounds. This is a State issue.

SCOTUS has ruled at least 15 times, including the recent decision, in matters involving marriage and has affirmed repeatedly that marriage is a fundamental right (see here). Perhaps the most closely related case to the recent decision is the Loving v. Virginia case. This decision repealed anti-miscegenation laws allowing interracial couples to marry in 15 states that banned their marriages before the decision. This shows a clear precedent of the SCOTUS overturning State laws on marriage due to Fourteenth Amendment violations.

Concern: This sets the stage for legal polygamy.

While some of the arguments used in favor of marriage equality for same-sex couples can be used in favor of polygamy, there are some important exceptions. The Fourteenth Amendment used to justify the recent decision does not apply to polygamy. For the Fourteenth Amendment to apply, the State must allow some groups to be polygamists while not allowing other groups the same access to the law. There is no inequality where everyone is treated the same and only allowed one spouse.

You may say this applied to SSM as well as everyone could pick one spouse of the opposite sex. The problems with this thinking is that same-sex couples were denied a marriage partner with someone they were attracted to while heterosexual couples were not denied. Also, from a sexual standpoint, a woman could marry a man, so why couldn't a man marry a man? The arguments against SSM could not find a convincing reason that the State should be allowed to discriminate on this basis. On the other hand, nobody is born a polygamist and their choice in finding a marriage partner is not limited any more than any other person.

Concern: People will be able to marry animals, children, siblings or inanimate objects.

Civil marriage is a legal agreement. Most of these examples, namely animals, children and inanimate objects cannot consent to such an agreement. They simply cannot enter into any legal agreement, especially not one as important as marriage. Allowing same-sex couples to marry doesn't change this.

Allowing same-sex couples to marry doesn't change laws against incest and will not allow siblings or other members of the immediate family start marrying each other. There are compelling reasons for this restriction. One is the risk of undue influence. One member of the family may be able to exert power over another due to their existing close relationship resulting in the inability to consent to the marriage contract freely. Another is that marriage is meant to establish kinship between two individuals. This already exists with members of ones immediate family.

Concern: God defined marriage. Man can't change what God has defined.

The SCOTUS decision affected Civil Marriage, not religious marriage. If your religion believes that God defines marriage only between man and woman, then this decision doesn't change that. However, the laws of the United States of America are not based on religious dogma. The secular nature of the government means that laws cannot put the beliefs of those that think God has defined marriage one way over those that do not hold that view without a compelling, secular reason. There is no compelling, secular reason to restrict marriage to one man and one woman so the laws banning same sex people from marrying were overturned.


Tags: ,

Politics | Religion


by Web Master 28. June 2015 01:00

Welcome to the WarnerBrother.com BLOG



Here you will find musings, deep thoughts, observations and rants from your friendly Warner Brother Web Master.