This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @StartDate DATETIME | |
DECLARE @EndDate DATETIME | |
SELECT | |
@StartDate = '2012-01-15',-- my start date | |
@EndDate = '2012-02-02' -- my end date; | |
; --(If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.) | |
WITH date_range(calc_date) AS ( | |
SELECT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
birthday = Date.parse('2013/03/27'); | |
age = ~~((Date.now() - birthday) / (31557600000)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE RULE [dbo].[DR_EMAILLADDRESS] | |
AS | |
@col LIKE '%_@_%_.__%' | |
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ICustomJsonResult | |
{ | |
bool Success { get; set; } | |
string Message { get; set; } | |
CustomJsonResult Succeed(); | |
CustomJsonResult Succeed(string message); | |
CustomJsonResult Fail(); | |
CustomJsonResult Fail(string message); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runas /netonly /user:myDomain\myUser "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe" | |
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
OBJECT_NAME(F.object_id) AS [table], | |
index_type_desc, | |
avg_fragmentation_in_percent, | |
ISNULL(name,'heap') AS [index] | |
FROM | |
sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS F | |
INNER JOIN | |
sys.indexes AS I ON F.object_id = I.object_id AND F.index_id = I.index_id | |
ORDER BY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnModelCreating(DbModelBuilder modelBuilder) | |
{ | |
//MyDataContext: is my current database context | |
var configurationTypes = typeof(DataContext).Assembly.GetTypes() | |
.Where(t => t.IsAbstract == false && | |
t.BaseType != null && | |
t.BaseType.IsGenericType && | |
(t.BaseType.GetGenericTypeDefinition() == typeof(EntityTypeConfiguration<>) || | |
t.BaseType.GetGenericTypeDefinition() == typeof(ComplexTypeConfiguration<>))) | |
.ToArray(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- http://gallery.technet.microsoft.com/scriptcenter/Script-for-rebuilding-all-8d079754 | |
USE DatabaseName --Enter the name of the database you want to reindex | |
DECLARE @TableName varchar(255) | |
DECLARE TableCursor CURSOR FOR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class RandomExtensions | |
{ | |
public static string NextString(this Random source, int length) | |
{ | |
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | |
var result = new string( | |
Enumerable.Repeat(chars, length) | |
.Select(s => s[source.Next(s.Length)]) | |
.ToArray()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number.prototype.formatNumber = function (decimalPlaces, thousandsSeparator, decimalSeparator) { | |
decimalPlaces = isNaN(decimalPlaces = Math.abs(decimalPlaces)) ? 2 : decimalPlaces; | |
decimalSeparator = decimalSeparator == undefined ? "." : decimalSeparator; | |
thousandsSeparator = thousandsSeparator == undefined ? "," : thousandsSeparator; | |
var number = this.toFixed(decimalPlaces); | |
if (decimalPlaces) { | |
var i = number.substr(0, number.length - (decimalPlaces + 1)); | |
var j = decimalSeparator + number.substr(-decimalPlaces); | |
} else { |
OlderNewer