Wednesday, January 27, 2016

Get Total Rows and size for all tables in SQL Server


Here is the query to find total records for all tables along with size 


DECLARE @size VARCHAR(10)
DECLARE @dividedby INT


SET @size= 'MB'  -- change this to GB you'll get size in Gb otherwise  it will be in MBs

IF @size='GB'
SET @dividedby = 1048576

ELSE
BEGIN

SET @dividedby = 1024
SET @size='MB'

END


CREATE TABLE #temp (
TableName sysname ,
TotalRows BIGINT,
reserved_size VARCHAR(500),
data_size VARCHAR(500),
index_size VARCHAR(500),
unused_size VARCHAR(500))

SET NOCOUNT ON
INSERT #temp
EXEC sp_msforeachtable 'sp_spaceused ''?'''
SELECT a.TableName,
a.TotalRows,

 CAST(ROUND((CAST(REPLACE(a.data_size, ' KB', '') AS DECIMAL(20,4))/@dividedby),4) AS NUMERIC(36,4)) 'Data size',
 CAST(ROUND((CAST(REPLACE(a.reserved_size, ' KB', '') AS DECIMAL(20,4))/@dividedby),4) AS NUMERIC(36,4)) 'Reserved size ',
 CAST(ROUND((CAST(REPLACE(a.index_size, ' KB', '') AS DECIMAL(20,4))/@dividedby),4) AS NUMERIC(36,4)) 'Index size',
 CAST(ROUND((CAST(REPLACE(a.unused_size, ' KB', '') AS DECIMAL(20,4))/@dividedby),4) AS NUMERIC(36,4)) 'Unused size ',
 @size 'size in '

FROM #temp a
ORDER BY  TotalRows DESC

DROP TABLE #temp



Saturday, November 22, 2014

Best VPN in Pakistan



Strong VPN is most suitable and Best VPN for users in Pakistan and it's speed also good and you get it $25-$30 for 3 month . I've used it and found it the best VPN for changing IP and I was able to open YouTube by using Strong VPN without any issue. Moreover Strong VPN guarantees that there  will be no monitor, record or store logs for any single customers VPN activity. They also support live chat 24x7 . They do not store web traffic data, including websites visited, files downloaded, etc

I would recommend you to use strong VPN for at least  few days and if you don't like it you can get  a full refund and they offer a 7 day money back guarantee for any reason .