Friday, November 15, 2019

SQL Server script - automate refresh prd from test

This script will restore a copy of one database over another. This can be used to refresh Prod from Test which is a pretty common request. What makes this script useful is that it queries msdb for the most recent backup of the source database and uses that backup for the restore.

--declare variables
DECLARE @sqlCommand NVARCHAR(4000)
DECLARE @dbsource varchar(20) = 'Prod'
DECLARE @dbtarget varchar(20) = 'Test'
Declare @BackupFileName varchar(max)

--query for the most recent backup of the source
SET @sqlCommand = 'select @BackupFileName = [physical_device_name]
from msdb.dbo.backupset A, msdb.dbo.backupmediafamily B 
where type = ''D'' and A.media_set_id = B.media_set_id 
 AND A.database_name = ''' + @dbsource + 
''' AND backup_finish_date = 
(select max(backup_finish_date) 
from msdb.dbo.backupset A, msdb.dbo.backupmediafamily B 
where type = ''D'' and A.media_set_id = B.media_set_id 
AND A.database_name = ''' + @dbsource + ''')'

--print @sqlCommand
EXEC sp_executesql @sqlCommand, N'@BackupFileName varchar(max) OUTPUT', 
@BackupFileName = @BackupFileName OUTPUT

--SELECT @BackupFileName ReturnedName

--print @BackupFileName

--Now, lets do our restore
SET @sqlCommand = 
'USE [master]
RESTORE DATABASE ' + @dbtarget + '
FROM  DISK = N''' + @BackupFileName  + '''

USE [master]

--print @sqlCommand
EXEC sp_executesql @sqlCommand

Thursday, November 7, 2019

Proactive or Reactive

Proactive or Reactive… 
You have many chances to choose whether to be proactive or reactive every day. Reactive people make choices based on impulse. They can explode at any time. Proactive people make choices based on values. They think before they act. They recognize they can’t control everything that happens to them, but they can control what they do about it. Unlike reactive people they are in control.

Besides feeling like victims, reactive people: 

  • Are easily offended
  • Blame others
  • Get angry and say things they later regret
  • Whine and complain
  • Wait for things to happen to them
  • Change only when they have to

 Proactive people: 

  • Are not easily offended
  • Take responsibility for their choices
  • Think before they act
  • Bounce back when something bad happens
  • Always find a way to make it happen
  • Focus on things they can do something about, and don’t worry about things they can't

Try these:

  1. Be the first to say Hello.
  2. Do something today that you have wanted to do but never dared. Leave your comfort zone and go for it. Ask someone to lunch or out on a date, raise your hand in class or a meeting, or join a team.
  3. Walk up and introduce yourself to someone new.
  4. The next time you feel like you were treated unfairly, don’t blow it off or cry about it, set aside some time to discuss it with that person and then see what you can learn.

Monday, November 4, 2019

Carbohydrates make you fat

Carbohydrates make you fat

Losing fat is not as hard as it might seem. All you need to do is to cut back on carbohydrates. When you eat carbohydrates, they get converted into glucose by insulin (a metabolic hormone). Too much glucose can be toxic so your pancreas sends out even more insulin to manage this. Now, instead of burning fat as fuel, you are converting calories into fat and storing it. Your body is great at converting carbs into fat and will gladly do that if there are too many carbs in your diet. 

I found this picture on a site that thinks this is all bunk but oddly enough, it pretty much lays it out for you:

Gain muscle, Burn fat

Try to exercise to exhaustion twice a week on an empty stomach when insulin levels are low. This will force your body to release human growth hormones which allows you to use fat for fuel instead of glucose. Do not eat for an hour after the exercise to keep your level of growth hormones higher longer which will help build muscle and burn fat. If you want to burn fat, you have to gain muscle. The other benefit of this is that it will train your muscles to use more oxygen.  Muscle helps you stay lean by making you insulin sensitive. This means that you require less insulin and, thus, will lower your blood sugar. The key to losing fat is to lower insulin levels and increasing muscle is the best way to do this.

Here are six high-carb foods you are probably eating today:

  1. Bananas - In general, don't overeat high-carb fruits. Try handfuls not bowlfuls and focus on berries which are lower in carbs.
  2. Oatmeal
  3. Orange Juice
  4. Pasta
  5. Beer - liquid carbs
  6. Whole grains - better than refined carbs but they still jack up blood glucose and insulin.
Daily Carbohydrate Recommendations:
I found this chart here:

Here are some bad ways to lose weight:
  1. Exercise - Exercise is great for lots of health-related reasons but exercise alone is not the best way to lose weight. 
  2. Counting calories - Calorie-counters might eat carbs with low calories without knowing they are stimulating appetite. Try to focus on eating the right foods instead.
  3. Cheat day - If you find yourself talking about your upcoming cheat day a week in advance, and craving it, you probably just set yourself up to become addicted to that cheat day – and therefore bad food in general – by your diet plan. 
  4. Portion control - Portion control has the same problem as calorie-counting. If you eat the right food, portion control takes care of itself. 
  5. Cleanse - Science does not support cleanses. Try to find a diet plan that is not debunked by science.
  6. Fasting - Fasting will cause your metabolism to slow by 40%. This is why eating regular meals is essential when trying to lose weight.
  7. Diets - You might lose 10 pounds dieting but if you return to your normal diet you probably will gain it back. This is because you learned how to lose weight on the diet plan but not how to lose weight on your normal diet. 
  8. Willpower - Try knowledge instead. If you just apply knowledge of proper eating you will not need any extra willpower whatsoever. 
Now, click here for six undeniable facts of life.

Thursday, October 24, 2019

Ohio University and drinking alcohol

Ohio University and drinking alcohol

Ohio University is nestled in the rolling hills of Appalachian Ohio
in Athens. This scenic town is a mere 90-minute drive southeast from Columbus. With an approximate student population of 23,000, Athens, Ohio, is the quintessential college town.
Ohio University is well known as the nation’s top Party School. However, the school is trying to end this reputation and has implemented very strict drinking policies.

Before we get to that, here are some reasons why they have the reputation.

  1. Court Street
    The red bricks on this historic street are famous. The street is only about a half mile but there are bars up and down. Court Street is well known for drink specials and drunken naughtiness. However, this street is also notorious for undercover cops that lurk in the shadows and into the bars so be careful.
  2. Bong Hill - named for all the potheads who make the climb.
  3. Green Beer Day - Yay! The beer is green!
  4. Win Or Lose, Bobcats Booze - Chants of “win or lose, Bobcats booze,” can be heard late into the night on Court Street after whatever game was just played.
  5. Welcome Weekend - a whirlwind experience where newcomers are encouraged to drink up on that first Friday night.
  6. Homecoming - Kegs and Eggs typically begin at 5 a.m. followed by 24 hours of drinking on Court Street.
  7. Fest Season - plenty of drinking and a musical festival to boot.
  8. Halloween
    The City of Athens closes Court Street and madness ensues.
  9. Alumni - Just ask any OU alum about their time at OU and you will hear a drunken tale or three.
  10. The Bobcat Attitude - they embrace their reputation.

With all that said, if you are underage, you should think twice about drinking when partaking in any of the above activities.

OU Policy
Despite all of this fun, OU is actually the wrong school for people under 21 years old that want to drink. The OU policy is very strict compared to most schools. It gives you two strikes, with the second being a semester suspension. A strike can come from a dorm write-up, off-campus violation, or through the notorious undercover cops in jeans and hoodies that make their way into bars. These sneaky officers lay low for a little while then, out of nowhere, arrest the unsuspecting teen for drinking at the wrong place at the wrong time. The university condones this as part of the strict policy. The city loves this because it is a revenue source. Anyway, a student can face probation after getting caught in the dorms or at the bars. You can even get reported by your RA if they smell it in your room. It may not seem fair when it seems like most underage kids are drinking but oh well.

Do NOT urinate in public
Many assume the most common student arrests are due to either underage drinking or open container violations. The leading cause of arrest on Ohio University’s campus is public indecency. This is usually because the lines at the bathroom are too long so people take their business outside. Don’t allow yourself to get popped for this!

If you get caught
If you get caught by the Athens police (who are out to get you), you will be given a court date. If it is your first offense, they will give you diversion which will consist of:

  1. Read a book and do a book report
  2. 8 hours of community service
  3. 3 hours of alcohol training
The total cost will be around $400 but at least you won't have a record (assuming you complete the 3 steps). I hope it was worth it.

If you are underage and must drink, here are some tips:
  1. Do not drink in a bar even if they let you in.
  2. Do not buy alcoholic beverages even if some store or bar will sell it to you.
  3. Do not drink on the streets or in public at all.
  4. Do not overdo it. This is good advice anyway. Why do you want to get so drunk you can't even enjoy yourself?
  5. Do not drink in the dorms. The RA can report you.
  6. Drinking at a house is safe but do ALL of your drinking in the house and DO NOT overdo it (see tip #4).
  7. Remember that the police are out to get you. The city of Athens makes a lot of money preying on teenagers who are drinking.
People don't care
If you are not 21 and do not want to risk suspension, just don't drink. People do not care if you don’t want to drink. Don’t feel like you have to do certain things to fit in. This is college so no one actually cares. Live your life to the fullest but don’t make stupid decisions that will haunt you.

Tuesday, October 22, 2019

Relationship advice


Center - Do not make someone the center of your life. If you center your life on someone...
  1. You’re no longer hard to get which is a bad look. 
  2. It’s irritating. Imagine having someone build their entire emotional life around you. Yuck!
  3. You will come off as desperate and needy. Avoid that.
Bad signs
  1. Often assessing your relationship a lot or asking "Where do we stand?"
  2. When you reach out and they don't reach back.
  3. You only meet on their terms.
Instead remember...
  1. Don't chase people. 
  2. Work hard and be yourself. The right people will find their way into your life. 
  3. Before you go looking for the right person, be the right person.
And finally...
  1. Beware of someone who is only focused on their own interests, at the exclusion of your's.
  2. Meet people where they are, versus where you think they should be.
  3. Don't try to change someone. A commitment held together only by threats and restrictions isn't one at all. Accept someone as-is or leave.
  4. Never trust anyone that lies to you.

Be sure to read more wisdom here.

Casablanca, Morocco Travel facts

Welcome to Casablanca, Morocco!

An Old Friend 

History - Morocco has a unique place in early American history. In 1777, it was the first foreign country to recognize the United States. The Moroccan-American Treaty of Friendship of 1786 remains our oldest unbroken alliance treaty. 

Casablanca, Morocco’s largest city, also has a special place in American culture. The 1942 movie by that name, starring Ingrid Bergman and Humphrey Bogart, won the Academy Award for Best Picture. It is widely regarded as an American classic.  

Tourism - Morocco’s economy is stable, and tourism is an important industry, just behind agriculture. Each year the country welcomes millions of visitors. Many flock to the urban caf├ęs, where they can sip mint tea and enjoy the spectacle.
Morocco is culturally diverse, and several languages are commonly spoken here, including Arabic, Berber, French and Spanish. It’s not unusual for Moroccan speakers to move from one language to another in mid-sentence. 

Food - By now you must be hungry. Dining in Casablanca is bound to be a memorable experience. Moroccan cuisine combines Berber, Portuguese, Spanish, Middle Eastern and African influences. Chicken is the preferred meat, along with beef and lamb, and cumin is the most widely used spice. (They use it on everything.) Even the couscous — the real stuff, not the boxed kind — can be a real treat for the unsuspecting palette.   

are a popular way to travel in Morocco. They are relatively inexpensive and tend to run on time. You can take the Marrakesh Express, or head out to Fes, a popular spot for shoppers, food lovers and music fans. You might need to take a camel to the sand dunes of Erg Chebbi, or to visit Berber villages in the Atlas Mountains. For a quiet place where you can reflect on your African adventures before returning home, check out Moulay Idriss, Morocco’s holiest city. 

Fun Fact: At the Strait of Gibraltar,
Morocco is less than 14.4 km (9 miles) from Spain. It takes about 4-5 hours for strong swimmers to make the crossing, and each year dozens of swimmers give it a try. 

Now, check out Petra, Jordan by clicking here.

Algiers, Algeria Travel facts

Algiers, Algeria
‘Algerian Pompeii’

Size - Algeria’s land mass is the largest of any African country, and the 10th largest in the world. Its area exceeds 900,000 square miles — four times the size of Texas — although nearly 90% of this land is in the Sahara Desert, and mostly uninhabited.

History - Algeria has a long and fascinating history. It was a Phoenician trading hub, and later a Roman colony. Prior to French occupation in 1830, it was a stronghold for Barbary pirates. In Algiers, you can visit the Martyrs’ Memorial
to those who fought and died for Algeria’s independence, won in 1962. The 300-foot memorial features three giant palm fronds joined at the top by a dome that protects an eternal flame. It’s just one of many impressive monuments and architectural treasures in the city.

Others include:
Great Mosque of Algiers.
Built in 1097, it is the oldest mosque in the city, and a rare remaining example of Almoravid architecture.
Djama’a al-Djedid Mosque.
Built in 1660, it combines Ottoman style with Turkish, Italian and Andalusian architecture.
Notre Dame d’Afrique.
Built in 1872, this Neo-Byzantine-style Catholic basilica is a near-copy of the cathedral in Marseille, France.

There are other antiquities to explore, including the ancient Roman ruins at Timgad — dubbed the “Algerian Pompeii.”
But after all your sightseeing in arid climates, perhaps you’re ready to spend some time by the sea. You can do this at Sidi Fredj,
one of Algeria’s most popular seaside resort towns. Or, better yet, you can cool off at Aquafortland, a waterpark and spa in Algiers that features three swimming pools and four water slides.

Fun Fact: Most of Algeria’s economy is driven by oil and natural gas exports. It’s external debt is extremely low. Debt-free is a great goal for all of us to have!

Now, check out Casablanca, Morocco by clicking here.