Skip to content

Instantly share code, notes, and snippets.

@DoubleBrotherProgrammer
DoubleBrotherProgrammer / FindColumnInDatabase.sql
Created August 8, 2011 18:15
Find column across all SQL Server databases
/* Find column in all databases */
DECLARE @db_name varchar(100),
@col_name varchar(100),
@sql_statement nvarchar(MAX)
-- column you are looking for
SET @col_name = 'PLANNED_SAMPLE_ID'
-- fill cursor with database names
@DoubleBrotherProgrammer
DoubleBrotherProgrammer / replaceDoubleQuotes
Created June 29, 2011 05:24
Replace all double quotes in a string with single quotes using C-SHARP ( C# )
#region removeQuote
/// <summary>
/// Replace all double "s in a string with single 's
/// * this also removes &quot;
/// </summary>
/// <param name="dirty"></param>
/// <returns></returns>
public static string replaceDoubleQuotes( string dirty )
{
@DoubleBrotherProgrammer
DoubleBrotherProgrammer / fsearch.bat
Created January 12, 2011 20:10
Simple file search batch file for windows. Command line usage : fsearch {full filename that you're looking for}. EX : To search your entire C:\, drop this bat into C:\, drop to cmd, type "fsearch readme.txt"
@echo off
@echo.
@echo '%1'
@echo -------------------------------------------------------------------------------
@echo.
dir /s /b /o:g %1
@echo.
@DoubleBrotherProgrammer
DoubleBrotherProgrammer / kill_user_sessions.sql
Created January 4, 2011 03:12
Kill all user sessions in SQL server
-- init vars
DECLARE @sessID int,
@dbName varchar(50),
@userName varchar(50)
SET @dbName = 'DA413' -- your database name
SET @userName = 'DA413' -- sql user account to look for
-- use a cursor to store all session_ids
@DoubleBrotherProgrammer
DoubleBrotherProgrammer / Tables_Ending_With_UPPERCASE_X.sql
Created December 8, 2010 20:27
How to find all database tables whose names end in an UPPERCASE X, using tsql
-- Give me all tables ending with an UPPERCASE X
SELECT table_name, SUBSTRING( table_name, LEN(table_name), 1 ) as 'end'
FROM INFORMATION_SCHEMA.TABLES
-- SELECT ascii('X') = 88
-- SELECT ascii('x') = 120
WHERE ASCII( SUBSTRING( table_name, LEN(table_name), 1 ) ) = 88
@DoubleBrotherProgrammer
DoubleBrotherProgrammer / AIR_install_directory.as3
Created November 8, 2010 05:14
Get the root install folder of an AIR application
// split path using applicationId
var _appDir:Array = File.applicationDirectory.nativePath.split(
NativeApplication.nativeApplication.applicationID, 1
);
// first item in array = root folder
trace( _appDir[0] );
<html>
<head>
<title>20 min datepicker</title>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script>
// id of HTML field to associate Datepicker with
var DT_FIELD = "date_field";
Use AdventureWorks
-- fill up temp table 1 ( [Schema], [Event] )
SELECT DISTINCT [Schema], [Event]
INTO #tempTbl1
FROM DatabaseLog
ORDER BY [Schema], [Event]
-- create delimited list
SELECT [Schema],
USE AdventureWorks;
-- create a comma delimited list of CountryRegionCode per CurrencyCode
SELECT CurrencyCode,
MAX( COALESCE( CountryRegionCode + ', ', '') + CountryRegionCode ) AS 'RegionCodes'
FROM Sales.CountryRegionCurrency