Tuesday, August 7, 2012

How could you beautify SQL script online?

How could you find out all the table names having a specific column name in SQL?

SELECT COLUMN_NAME, TABLE_NAME 
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%<Column Name>%'

or

SELECT SO.NAME, SC.NAME
FROM SYSOBJECTS SO INNER JOIN SYSCOLUMNS SC
ON SO.ID = SC.ID
WHERE SC.NAME = '<Column Name>'

What is the difference between "IN" and "BETWEEN"?

"BETWEEN" requires a range of values whereas "IN" demands a list of values to operate on.

How could you test your code online?

You can take advantage of the following Online Compilers :

http://ideone.com/
http://codepad.org/
http://compileonline.com/

How could you delete duplicate rows?

DELETE FROM <Table Name>
WHERE rowid not in ( SELECT MIN (rowid)
FROM <Table Name>
GROUP BY column1, column2, column3, ... );

Monday, August 6, 2012

Friday, August 3, 2012

What is the difference between array and hash (associative array) in Perl?

An array is a list of ordered items where as a hash is a set of key-value pairs of unordered items.
To be precise, hash is for mapping and arrays for ordering. Numerically indexed array is more efficient than that of the hash lookup.Hash is slower than array.

If you have things in a line or ordered or in a sequence, use an array. For instance:
- A list of files to read
- A list of people in a queue

If you have a bag of unordered things to look up, use a hash. For example:
- An index of last names, looked up by first name
- An index showing the size of files, looked up by name

What is difference CTLIB and DBLIB?

 An important difference between CTlib and DBlib lies in how the SYBASE environment variable
is handled. DBlib only checks for the SYBASE variable when it requires access to the interfaces file. This allows for definition of the SYBASE variable in the script. CTlib requires the SYBASE variable to be defined BEFORE initialization. If the variable is not defined then CTlib will not initialize properly and the script won't run.