Tuesday, August 7, 2012

How do you pass output of a command as a parameter to Perl script?

"xargs" allows you to use the output of one command as the argument to another command. For instance :

<Command Name> | xargs perl myscript.pl

How do you find tables with particular column by name in Sybase?

SELECT Object_name(id)
FROM syscolumns
WHERE name = '<Coulmn Name>'


or

SELECT sysobjects.name
FROM sysobjects, syscolumns
WHERE sysobjects.id = syscolumns.id

AND syscolumns.name = '<Column Name>'

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