Wednesday, June 27, 2012

SQL Quick Reference

Update using From Clause
Most of the time we need to update table using reference from another table where we need to do join. The SQL query used in Netezza/teradata is slightly different than oracle. The syntax for Netezza is as
update tbl1 a
    SET a.col1=b.col1
FROM (select col1,col2 from tbl2) B
    WHERE a.col2=b.col2

Thursday, May 31, 2012

MS-DOS Helpful Commands

Overview: Record count check


We often need to get record count of a file in Windows. We can always open the file in editplus or notepad++ to get the record count in status bar of GUI, but not all the computer has these editors. Also if the file is of higher size, it is difficult to open in editor. We can get the record count using MS-DOS commands.


Print Line Number in the begining of each line
Command: findstr /R /N "^" file1.txt

Get record count of a file using MS-DOS
Command: findstr /R /N "^" file.txt | find /C ":"

Description - This will tell the record count in a file. It basically searches the string with ":". ":" is added as part of first part where line number is appeneded with ":"

Note: Above commands are searched from some other tutorial websites and I just placed here for ease of access in one place.

Get List of all files from a directory and its subdirectory

dir /s /b /o:gn