cookieChoices = {};

Wednesday, 4 May 2016

Find Byte Size Of All tables in database

Find Byte Size Of All tables in database:



SELECT sob.name AS Table_Name,  
  
SUM(sys.length) AS [Size_Table(Bytes)]  
  
FROM sysobjects sob, syscolumns sys  
  
WHERE sob.xtype='u' AND sys.id=sob.id  
  
GROUP BY sob.name 

Retrieve All dependencies of Stored Procedure:

Retrieve All dependencies of Stored Procedure:


;WITH stored_procedures AS (  
  
SELECT  
  
oo.name AS table_name,  
  
ROW_NUMBER() OVER(partition by o.name,oo.name ORDER BY o.name,oo.nameAS row  
  
FROM sysdepends d  
  
INNER JOIN sysobjects o ON o.id=d.id  
  
INNER JOIN sysobjects oo ON oo.id=d.depid  
  
WHERE o.xtype = 'P' AND o.name LIKE '%SP_NAme%' )  
  
SELECT Table_name FROM stored_procedures  
  
WHERE row = 1

Rebuild All Index of Database

Rebuild All Index of Database

Use Command:


EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"  
  
GO  
  
EXEC sp_updatestats  
  
GO

Get All Stored Procedure Relate To Table

Get All Stored Procedure Relate To Database


Use Command: 

SELECT DISTINCT o.name, o.xtype  
  
FROM syscomments c  
  
INNER JOIN sysobjects o ON c.id=o.id  
  
WHERE c.TEXT LIKE '%Table_Name%' AND o.xtype='P'

Get All Stored Procedure Relate To Database

Get All Stored Procedure Relate To Database


Use Command: 

SELECT DISTINCT o.name, o.xtype 

FROM syscomments c 

INNER JOIN sysobjects o ON c.id=o.id 

WHERE o.xtype='P' 

Display Text of Stored Procedure, Trigger, View


Display Text of Stored Procedure, Trigger, View:



USE COMMAND : exec sp_helptext @objname = 'Object_Name' 

Tuesday, 3 May 2016

Retrieve List of All Database

Retrieve List of All Database:


Use command => EXEC sp_helpdb