Hey guys , i got some SQL code snippets to show you.

Get column names from MSSQL :
Code:
SELECT tablename=sysobjects.name,
         columnname=syscolumns.name,
         datatype=systypes.name,
         length=syscolumns.length
    FROM sysobjects 
    JOIN syscolumns ON sysobjects.id = syscolumns.id
    JOIN systypes ON syscolumns.xtype=systypes.xtype
   WHERE sysobjects.xtype='U'
ORDER BY sysobjects.name,syscolumns.colid
Get ALL table names for a database :
Code:
SELECT * FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = 'Foo' ... where Foo is the table name you want details for.
Get total rows of table:
Code:
SELECT count(*) FROM <table_name>
Get total rows having field value null:
Code:
SELECT count(*) FROM <table_name> where <field_name> is null
Get column names of table:
Code:
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = <table_name>
Get all rows of table:
Code:
SELECT * from <table_name>
Delete all rows of table (USE WITH CAUTION):
Code:
delete from <table_name>
Delete table (USE WITH CAUTION):
Code:
drop table <table_name>
Get reasons of job failure of SQL Agent jobs :
Code:
select * from MSDB.dbo.sysjobhistory