Sunday, August 18, 2013

Copy that Floppy

So currently I am in the process of migration of data from one database to another. They are mostly the same so it should be just an export here and an import there...right?

Well let's go over step one of anytime you are going to be migrating anything. Practice locally. If you follow the steps below you can create a working copy of a MS SQL database on your local machine.

The first step is to install SQL server management studio. You can do a Google search for that yourself and get the version you need. In this demo we will be using 2008 R2, old, but that is what we use at work.

It is a basic windows install using a wizard. So if you can't figure this part out, you best stop now. We will be working in the command prompt shortly and I don't want to cause a panic attack.

Alright you installed? Good. The next step is to connect to the database that you need to copy. Find the database and right click on it. Then select the Tasks > Generate Scripts. Now depending on your access you have on the database you might can select all or pick what you need from the check boxes below. I personally select the bottom radio button for "Select specific database objects". From there select Table, Stored Procedures, User-Defined Functions, and users. Yes that is all of the database, yes there is a radio button for select all. For some reason I don't have access to use that button, go figure.

Now select next and you see save to file, save to clipboard, save to query window. Chose save to file, this will be a large file, few hundred MB to a GB depending on the number of rows you will be copying. I'll explain in another step why you must use the file. So make sure the file is named something that you can remember and find it in a minute. I named mine ScriptToCopy.sql

Now here comes the part that I miss every time, part of the reason why I am writing this post is so I don't forget. Click the Advanced button. Most of this will stay as is, but there are a few places we need to update. First is Append to File, make that true. Even though we said to on the last screen, we must do it here as well. Then scroll down to Table/View Options. The field directly above this will be Types of data to script, make sure to select Schema and Data. This way you get your tables and rows. Then below that, you can select your indexes and triggers if you need them. Select OK, then select next, next, and wait for your script to copy.

Alright now that you have your script, it is time to create your local database. Step one is connect to your local database, mine is SQLEXPRESS. You will need to create an empty database locally with the same name as the one that you just copied. So this one was named BlobPostDatabase.

Now here comes the fun part. Open up your command prompt, navigate to the directory where you script is located, and type in the following command.

sqlcmd -S localhost\SQLEXPRESS -i ScriptToCopy.sql

So as you can see, we call the sqlcmd command. -S is the server that your database will be on. So mine is localhost(or you can use your PC name, I suggest localhost)\SQLEXPRESS. -i Stands is the input file command. It tells sqlcmd to run this file.

Now why do I have to do this in the command prompt? Since this file is large, see above for file size, you will run out of memory trying to use the GUI. I Have a machine with 8GB physical and another 8 virtual, so trust me that you will run out. So there you go, you now have a local copy of your database.

Next up will be steps to prepare for a migration. Don't expect this post next week or the following, I am still figuring this out and will be getting help from our DBA on this process. Hopefully I will have some cool tricks to share.

Monday, August 5, 2013

Karma Drives You To Succeed

Every now and again I find some tool that makes life not only simpler, but just better overall.

I know you have seen a million and one adds for free credit reporting. This is another one of those free credit report tools, only this one is actually free and gives great information. If you haven't heard about it yet, you should give creditkarma.com a try.

When you first sign up it asks for some basic information about yourself; name, address, phone number, DOB, last four of you social. Only the last four seemed odd to me. I figured you would need more than that. But then I got the ID verification quiz and it all made sense why they only needed the last four. They were going through a testing service to verify who I was, and that service probably has the rest. Or there is black magic that is unknown to me.

Anyway, on to the cool parts. So it pulls your credit in and list all open accounts that you have attached to your social security number. It found my credit cards, bank accounts, loans, etc. Anything and everything that might be affecting my credit.

It showed me all my open loans which included student loans. Those annoying things that will never go away, trust me they find you. At first I noticed, hey that value is higher than I remember. The second thing I noticed is was that one of these loans had missed a few payments. Mostly because I was unaware that I even had this loan. I thought I had consolidated all of these. So what was this random loan that was dinging my credit? If I wouldn't have signed up I wouldn't have known about this loan.

The next thing is that it gives you tips on how to make your credit look better. Trust me, if I could just put a bow on my score to make it better, I would. Things like your credit to debt ratio. I thought that as long as I used my credit card and payed it off at the end of the month would be fine, well sorta. As long as you are not using more than 30% of your available credit, you get a higher score. Any more than that, and your score starts going down.

Honestly though, the best part of the application is the dashboard. The dashboard allows me to link all my accounts into one screen. This makes life easier as I only have to log into one place to see all of my bank accounts and credit cards. The next thing I need to figure out it how to link my retirement and stock purchases into this tool and I will be set.

Also side note. If you request information on a loan, Credit Karma does not screw around. I request information on a loan to get a down payment on a car. About a dozen emails and actual pieces of mail later, I'm still getting letters from banks telling me rates and payment schedules if I wanted to get a loan from them. So be prepared to have applications for loans to become automated.

Combine this tool with http://www.iwillteachyoutoberich.com/ and you will be set for awhile. Do yourself a favor and stay ahead of this shit early. 1 year of being stupid is now costing me 5 years of catching up.