Pages

Thursday, 28 March 2013

So I'm learning batch ...

So I'm starting to learn batch from scratch( yes .. even though I do have a Comp Sci degree .. terrible aren't I) Its just been so long since I've done anything like this and I thought I have to start somewhere.. I'm also going to have to have a way to get to it easily away from my home computer, then an idea struck me. Why not here.

So to my fellow readers (mainly my partner and friends) prepare to be shocked ...

Dropping attached Sql Database

Here is the first one I made this week at work, nothing fancy just drops an attached database. I got sick and tired of constantly doing it and I did it infrequently enough that I forgot the syntax, but frequently enough for it to annoy me.

First you need to have the command in an .sql file
drop table Tablename

go

Then you need the actual batch file to run it
@echo off      <--ED: Still no idea what this line actually does but all batch examples I've seen have them

sqlcmd -i Filename

Thats it. Simple right? but it saves me so much time.

Setting a local environment variable

So where I work you need to set environment variables to allow for fancy dev functions. However once they are set you never really need to bother with them again. Unless you reinstall your working environment. That is where I came up with the idea for the other one
@echo off

setx Variable value

Once again very simple, but its a start.

No comments:

Post a Comment