jQuery Ajax helper method

//Helper method to call page methods with AJAX
function PageMethod(fn, paramArray, successFn, errorFn) {

var pagePath = window.location.pathname;
//Create list of parameters in the form:
//{“paramName1″:”paramValue1″,”paramName2″:”paramValue2″}
var paramList = ”;
if (paramArray.length > 0) {
for (var i = 0; i < paramArray.length; i += 2) {
if (paramList.length > 0) paramList += ‘,’;
paramList += ‘”‘ + paramArray[i] + ‘”:”‘ + paramArray[i + 1] + ‘”‘;
}
}
paramList = ‘{‘ + paramList + ‘}’;
//Call the page method
$.ajax({
type: “POST”,
url: fn,
contentType: “application/json; charset=utf-8”,
data: paramList,
dataType: “json”,
success: successFn,
error: errorFn
});
}

Find largest tables in db

from : http://stackoverflow.com/questions/2094436/how-to-find-largest-objects-in-a-sql-server-database

use

SELECT
t.NAME AS TableName,
i.name as indexName,
sum(p.rows) as RowCounts,
sum(a.total_pages) as TotalPages,
sum(a.used_pages) as UsedPages,
sum(a.data_pages) as DataPages,
(sum(a.total_pages) * 8) / 1024 as TotalSpaceMB,
(sum(a.used_pages) * 8) / 1024 as UsedSpaceMB,
(sum(a.data_pages) * 8) / 1024 as DataSpaceMB
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
sys.allocation_units a ON p.partition_id = a.container_id
WHERE
t.NAME NOT LIKE ‘dt%’ AND
i.OBJECT_ID > 255 AND
i.index_id <= 1
GROUP BY
t.NAME, i.object_id, i.index_id, i.name
ORDER BY
object_name(i.object_id)

SQL server express w/ profiler

http://stackoverflow.com/a/13612052/410622

 

You can activate the SQL Server Express Error Log in a way that it monitors all statements runned agaist every database. To do so you must run the following on an elevated command prompt (that is, a command prompt runned as administrator):

net stop MSSQL$SQLEXPRESS
net start MSSQL$SQLEXPRESS /T4032

Now, using the SQL Server Management Studio run the following:

dbcc traceon(3605, -1)

Now you can look at the ERRORLOG file within the Log folder of MS SQL folder (which may be “C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\Log” for the default installation of SQL Server Express 2012).