Sql Snipets

total rows of table
SELECT count(*) FROM

column names of table:

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = 'jamesjara'

all rows of table:

SELECT * from

Delete table (CAUTION):
drop table

Delete all rows of table (CAUTION):
delete from

job failure SQL Agent jobs:

select * from MSDB.dbo.sysjobhistory

total rows having field value null
SELECT count(*) FROM where is null

find a column or field name in a ALL database
SELECT table_name=sysobjects.name,
column_name=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 syscolumns.name='HACKCOLS"

0 pensamientos:

Post a Comment

feedback!