Wednesday, October 26, 2005

SQL: Migrating MySQL scripts to MS SQL

I had some database table creation scripts to migrate from MySQL to MS SQL.

Primary Key:
MySQL allows a primary key on the either of NULL, and NOT NULL declarations.
MSSQL only allows primary keys on fields that are NOT NULL

Date Fields:
MySQL uses a DATE field
MSSQL uses a DATETIME field

Table Creation with AutoIncrement:
MySQL uses keyword AUTO_INCREMENT
example:
CREATE TABLE mytable (
myfield1 integer(12) NOT NULL AUTO_INCREMENT,
myfield2 CHAR(9) NULL,
myfield3 CHAR(6) NULL,
PRIMARY KEY(myfield1)
);


MSSQL uses keyword IDENTITY(1,1)
example:
CREATE TABLE mytable (
myfield1 int IDENTITY(1,1) NOT NULL,
myfield2 CHAR(9) NULL,
myfield3 CHAR(6) NULL,
PRIMARY KEY(myfield1)
);


Create Table 'IF NOT EXISTS'
MySQL uses keywords IF NOT EXISTS
example:
CREATE TABLE IF NOT EXISTS mytable (
myfield1 CHAR(9) NOT NULL,
myfield2 CHAR(6) NULL,
PRIMARY KEY(myfield1)
);


MSSQL uses a query into a system table
example:
IF NOT EXISTS(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'mytable')
CREATE TABLE mytable (
myfield1 CHAR(9) NOT NULL,
myfield1 CHAR(6) NULL,
PRIMARY KEY(myfield1)
);


More information on autoincrement fields in MSSQL can be found at
an article on http://www.databasejournal.com

HUMOR: Anti- telemarketer Strategy (Counterscript)

http://www.xs4all.nl/~egbg/counterscript.html

A script to use vs. telemarketers calling to harrass you.

Monday, October 24, 2005

CSS: Force a Fixed Width HTML Webpage

Cross-browser content layout fix for variable-length content using CSS

BACKGROUND:
Firefox browser page has no vertical scrollbar unless the content exceeds the browser window height. IE always has a vertical scrollbar, it is merely greyed out when the content doesn't exceed the browser window height.

PROBLEM:
This can be a problem if you have some centered content in pages with the same layout but some content fits in the browser window and on other pages the content is taller than the window. Navigating from one page to the other appears as if the centered content is misaligned.

SOLUTION:
Include this stylesheet in your html code of the webpage to force a scrollbar even when its not necessary, for regular width pages.

<style type="text/css">
html { height: 100.1%; }

</style>

Friday, October 21, 2005

JAVASCRIPT: Make a pop up window

The following HTML code:

<form><input type=button value="Open new window"
onClick="myRef = window.open(self.location,'mywin',
'left=20,top=20,width=800,height=500,toolbar=1,
resizable=0');myRef.focus()"
></form>


Generates this:

Friday, October 14, 2005

COBOL: EBCDIC File Formats

I had some file formats I had to import into a database for work and it was in a strange format I had never seen before.

05 RECORD1-RAW                          PIC X(17).
05 RECORD1-AREA REDEFINES RECORD1-RAW
10 REC2-RAW PIC 9(9).
10 REC2-AREA REDEFINES REC2-RAW
15 REC3-F1 PIC X(3).
15 REC3-F2 PIC X(2).
15 REC3-F3 PIC X(4).
10 REC2-FOOTER PIC S9(6)V99.


I saw the word EBCDIC, and I was clued in that I was not using ASCII. I read somewhere that Mac still uses EBCDIC.

http://www.natural-innovations.com/computing/asciiebcdic.html is Google's top link for EBCDIC. But here is a cleaner looking table comparing ascii and ebcdic: http://www.simotime.com/asc2ebc1.htm

Wikipedia's link: http://en.wikipedia.org/wiki/EBCDIC

But what finally helped was when I found: http://www.discinterchange.com/reading_COBOL_layouts_.html

and then used http://www.discinterchange.com/TechTalk_signed_fields_.html to figure out signed fields like above.

Monday, October 03, 2005

APP: Backup DVDs to your hard drive (like ripping CDs)

After you've ripped you CD collection to your hard drive so you can listen to them whenever you want, you realize you have this hefty DVD collection and you wouldn't mind ripping this onto your hard drive. But DVDs don't have to take up a ton of space on your hard drive, just like audio CDs don't have to take up 700MB per CD.

Most DVDs for sale in North America are NTSC set at 720x480 resolution and can take up to 9.4 GB on a dual layer DVD, but with DivX or Xvid compression you can backup a DVD onto your computer to sizes between 700MB and 1400MB without significant quality loss.

Make a DVD Backup/How to rip the DVD

Download and install
DVD Decrypter and Auto Gordian Knot

Copy to Computer
Use DVD Decrypter to copy the DVD files to you computer's hard drive (minus encryption). These often take around 6-8GB but you can erase them when you're done.

Compress
Next, run AutoGK. Select the decoded DVD files on your computer. Select an output .avi file. Additionally, AutoGK allows you to choose the file size of your output file, in case you want to compress and back it up onto a CD or other media.

AutoGK is a front-end programs which actually runs a few other programs in the background to perform different tasks in video compression like audio compression, and codec specific tasks etc.

Play it
Now to play the .avi file in windows, all you need is something like Winamp 5.1 installed with video support(or windows media player if you must).

Housekeeping
Now, don't forget to erase the files generated by DVD Decryptor, once you have the output .avi file and you've test it and it works. These files take up a 6-8GB normally, so you really out to clear them off before doing another disc.

Saturday, October 01, 2005

APP: Make PDFs from any document (Windows)

PDF Creator an open source project is a great way to create PDFs for free.

A PDF is a platform independent document with fixed formatting, and once created, it cannot be edited, making it excellent for copyrighted material.

Install it, and it will create a new 'printer'. To create a PDF of a document, go to print the document, and select PDFCreator as the printer. When it goes to print it will ask you where you want to save the PDF.

SourceForge.Net Project site:
http://sourceforge.net/projects/pdfcreator