Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View terra819's full-sized avatar

Terra terra819

View GitHub Profile
@terra819
terra819 / get_table_sizes.sql
Created March 26, 2013 13:45
Get list of tables in a database with number of rows, reserved space, data, index_size and unused space.
declare @RowCount int, @tablename varchar(100)
declare @Tables table (
PK int IDENTITY(1,1),
tablename varchar(100),
processed bit
)
INSERT into @Tables (tablename)
SELECT TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_TYPE = 'BASE TABLE' and TABLE_NAME not like 'dt%' order by TABLE_NAME asc
declare @Space table (
name varchar(100), rows nvarchar(100), reserved varchar(100), data varchar(100), index_size varchar(100), unused varchar(100)
@terra819
terra819 / list_reports.vb
Created March 26, 2013 13:42
Get list of reports under a path and populate a dropdown list.
' sample reporting server url http://MyServer/ReportServer/ReportService.asmx
Private Sub LoadSampleReports()
Dim rs As New ReportingService
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim item As CatalogItem
For Each item In rs.ListChildren("/SampleReports", False)
If item.Type = ItemTypeEnum.Report Then
DropDownList1.Items.Add(New ListItem(item.Name, item.Path))
@terra819
terra819 / auto_crud_sproc_generator.sql
Created March 26, 2013 13:38
Auto generate crud sprocs. must grant permissions after running.
SET NOCOUNT ON;
-- User Preferences
DECLARE @prefix varchar(5);
SET @prefix = 'usp_';
-- End User Preferences
-- Create CRUD procedures
DECLARE DBtables CURSOR FOR SELECT name FROM sysobjects WHERE xtype = 'u' AND name != 'sysdiagrams'
@terra819
terra819 / webgrid_moreoptions.cshtml
Created March 26, 2013 13:36
Webgrid sample syntax with more options, paging
notes: default paging rows is 10, allow paging and allow sort is default = true. all attributes listed below are optional. a standard generic (auto gen col=true) can be called with a simple @grid.GetHtml()
@grid.GetHtml(
fillEmptyRows: true,
alternatingRowStyle: "alternate-row",
headerStyle: "grid-header",
footerStyle: "grid-footer",
mode: WebGridPagerModes.All,
firstText: "<< First",
previousText: "< Prev",
@terra819
terra819 / webgrid.cshtml
Created March 26, 2013 13:31
Webgrid sample syntax
@{
var grid = new WebGrid(Model, canSort: true, canPage: false, defaultSort: "Column1Value");
}
@grid.GetHtml(
columns: grid.Columns(
grid.Column("Column1Value", "Column 1 Heading", canSort: true),
grid.Column("Column2Value", "Column 2 Heading", canSort: true),
grid.Column("Actions",
format: @<text>
@Html.ActionLink("Action Link 1 Text", "ActionLink1Command") |
@terra819
terra819 / jquery_ui_modal.js
Created March 26, 2013 13:11
Open jquery ui modal popup
$("#divID").dialog({
title: 'Modal Window Title',
height: 250,
width: 650,
modal: true,
buttons: {
'OK': function () {
$(this).dialog('close');
} //Ok
}//buttons
@terra819
terra819 / ajax_post_json.js
Created March 26, 2013 13:08
Ajax getter/setter with json formatted data
$.ajax({
url: window.webRoot + 'Validations/SaveValidation',
data: JSON.stringify({data}),
type: "post",
contentType: "application/json",
success: function (resultData) {
// code to execute on success
}
});
@terra819
terra819 / jquery_onload.js
Created March 26, 2013 13:00
jquery document ready snippet
$(document).ready(function () {
// code to run on document ready
});