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
mysql> CREATE DATABASE newdbname CHARACTER SET utf8; | |
mysql> CREATE USER 'newdbuser'@'localhost' IDENTIFIED BY 'my_password'; | |
mysql> GRANT ALL PRIVILEGES ON newdbname.* TO 'newdbuser'@'localhost'; | |
mysql> \q |
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 | |
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 |
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 TextData, Duration/1000/60 [Duration (m)], Reads, Writes, CPU, StartTime | |
FROM fn_trace_gettable('F:\RestoreDB\HR 4.3.1\TSG01\TSG01_aCao.trc',1) | |
where 1=1 | |
-- and Duration > 10000 -- over 10s | |
and textdata is not null | |
-- and textdata LIKE N'%sp_replcmds%' | |
order by duration desc |
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 FUNCTION SplitString | |
( | |
@Input NVARCHAR(MAX), | |
@Character CHAR(1) | |
) | |
RETURNS @Output TABLE ( | |
Item NVARCHAR(1000) | |
) | |
AS | |
BEGIN |
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
-- PatternSplitLoop will split a string based on a pattern of the form | |
-- supported by LIKE and PATINDEX | |
-- | |
-- Created by: Dwain Camps 11-Oct-2012 | |
CREATE FUNCTION [dbo].[PatternSplitLoop] | |
( @String VARCHAR(400) | |
,@Pattern VARCHAR(500) | |
) RETURNS | |
@Results TABLE ( ItemNumber INT |
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
this.session.Query<Notice>().Where( n => | |
this.session.Query<User>().Any(u => u.UserId == "007" | |
&& !u.DismissedNotices.Contains(n) ); |
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 NhTransformers | |
{ | |
public static readonly IResultTransformer ExpandoObject; | |
static NhTransformers() | |
{ | |
ExpandoObject = new ExpandoObjectResultSetTransformer(); | |
} | |
private class ExpandoObjectResultSetTransformer : IResultTransformer |
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
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Dynamic; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
using Castle.ActiveRecord; | |
using Castle.ActiveRecord.Framework.Config; | |
using log4net.Config; | |
using NHibernate; |
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
IF OBJECT_ID(‘tempdb..#sometable’) IS NOT NULL | |
DROP TABLE #sometable |
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
using System; | |
using System.Security.Cryptography; | |
public class UniqueIdGenerator | |
{ | |
private static readonly UniqueIdGenerator _instance = new UniqueIdGenerator(); | |
private static char[] _charMap = { // 0, 1, O, and I omitted intentionally giving 32 (2^5) symbols | |
'2', '3', '4', '5', '6', '7', '8', '9', | |
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' | |
}; |
OlderNewer