lockworld
6/19/2017 - 7:52 PM

SQL Server Database and Server commands (These are for when you need to go beyond just table-level access).

SQL Server Database and Server commands (These are for when you need to go beyond just table-level access).

SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' 
ORDER BY TABLE_NAME
--https://stackoverflow.com/a/1171031

SELECT
        [name]
       ,create_date
       ,modify_date
FROM
        sys.tables
ORDER BY create_date DESC, modify_date DESC
select * from INFORMATION_SCHEMA.COLUMNS 
order by TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME
This set of gists helps when working with tables in SQL Server
/*
Use this query to find the start time, percent complete, and estimated completion time for a running backup or restore process
*/

SELECT session_id AS SPID
	,command
	,percent_complete
	,start_time
	,dateadd(second, estimated_completion_time / 1000, getdate()) AS estimated_completion_time
	,a.TEXT AS Query
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) a
WHERE r.command IN (
		'BACKUP DATABASE'
		,'RESTORE DATABASE'
		)