Friday, May 21, 2010

Merge - Upsert

MERGE INTO mergeD AS d
USING mergeS AS s
ON s.a = d.a
WHEN matched THEN
UPDATE SET d.achar = s.achar
WHEN NOT MATCHED THEN
INSERT (achar) VALUES (achar);

Quick Find Tables w/ Column Name Like

-- Utility: Quick Find Tables w/ Column Name Like
SELECT
'SELECT * FROM '
, t.TABLE_NAME
, 'WHERE Username LIKE ''kellyjo%'''
, ' -- '
, c.COLUMN_NAME
FROM INFORMATION_SCHEMA.TABLES AS t
JOIN INFORMATION_SCHEMA.COLUMNS AS c
ON t.TABLE_CATALOG = c.TABLE_CATALOG
AND t.TABLE_SCHEMA = c.TABLE_SCHEMA
AND t.TABLE_NAME = c.TABLE_NAME
WHERE t.TABLE_TYPE = 'BASE TABLE'
AND t.TABLE_CATALOG = 'foo'
AND c.COLUMN_NAME LIKE '%bar%'

Tuesday, May 18, 2010

Pre and Post pend Text to String

Sub preNPost()

' pre and post pend text to a line

Dim StartLine, EndLine, CurrentLine

StartLine = DTE.ActiveDocument.Selection.TopLine
DTE.ActiveDocument.Selection.EndOfDocument(True)
EndLine = DTE.ActiveDocument.Selection.BottomLine
DTE.ActiveDocument.Selection.StartOfDocument()
CurrentLine = DTE.ActiveDocument.Selection.CurrentLine

While (CurrentLine < EndLine)

DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
DTE.ActiveDocument.Selection.Text = "+ zzzz "
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.Text = " yyyy"
DTE.ActiveDocument.Selection.LineDown()
CurrentLine = DTE.ActiveDocument.Selection.CurrentLine

End While

End Sub

Friday, May 14, 2010

ASP 0131 Disallowed Parent Path

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q226/4/74.asp&NoWebContent=1


When you use relative paths in include statements with Microsoft Active Server Pages (ASP), browsing a Web page may return an error message similar to the following:
Active Server Pages, ASP 0131
Disallowed Parent Path
The Include file '../' cannot contain '..' to indicate the parent directory.
//, line
Back to the top
CAUSE
This is caused by disabling ASP's "parent paths" for a Web site or application...
This is caused by disabling ASP's "parent paths" for a Web site or application while using relative parent paths in an include statement.

Relative parent paths in include statements use the following form:




Back to the top
RESOLUTION
The best solution to the problem is to use absolute virtual paths from the root...
The best solution to the problem is to use absolute virtual paths from the root of the Web site instead of relative paths.

For example, if you use an include file named "mycode.inc" at the root of your server, the virtual path would be "/mycode.inc." If you use the same include file in a virtual directory named "/includes" on your server, the virtual path would be "/includes/mycode.inc."

The syntax example below illustrates how to implement virtual paths:





An alternative to using absolute virtual paths is to enable parent paths; however, this is not the preferred method. (See the notes in the More Information section for details.) This is accomplished for your default Web site by using the following steps:
Back to the top
Internet Information Services 7.0

1. Start Internet Services Manager.
2. Click Default Web Site, and then click Properties.
3. Double-click ASP in the Features pane.
4. Expand Behavior.
5. Click Enable Parent Paths.
6. Click True for Enable Parent Paths.
7. Click Apply.

Back to the top
Internet Information Services 6.0

1. Open the Internet Services Manager in the Microsoft Management Console (MMC).
2. Right-click on your Default Web Site and select Properties.
3. Click the Home Directory tab.
4. Click the Configuration button.
5. Click the App Options tab.
6. Click to select the Enable Parent Paths checkbox.
7. Click the OK button until you return to the MMC.

Back to the top

Utility: Quick Find Tables w/ Column Name Like

SELECT
'SELECT * FROM '
, t.TABLE_NAME
, 'WHERE Username LIKE ''kellyjo%'''
, ' -- '
, c.COLUMN_NAME
FROM INFORMATION_SCHEMA.TABLES AS t
JOIN INFORMATION_SCHEMA.COLUMNS AS c
ON t.TABLE_CATALOG = c.TABLE_CATALOG
AND t.TABLE_SCHEMA = c.TABLE_SCHEMA
AND t.TABLE_NAME = c.TABLE_NAME
WHERE t.TABLE_TYPE = 'BASE TABLE'
AND t.TABLE_CATALOG = 'Budget'
AND c.COLUMN_NAME LIKE '%user%'

Wednesday, May 12, 2010

How to Find the Process ID for the IIS Ap Pool

C:\WINDOWS\system32>cscript.exe iisapp.vbs

Note that if the process is not hosting any threads (or instances of a site) at that moment then will/may not show.

Debug Process to Attatch to

Particularly useful when traipsing through (inherited) project-less sites with embedded C# (no code-behind)...

For remote debugging of managed code

aspnet_wp.exe - XP

w3pw.exe - Vista / 2k3+

(Note that msvsmon.exe must be running on remote machine)

And for the JS attach to the client process (say IE) (especially when you cannot use something like FireBug because corp. only wants to support IE).

Friday, May 7, 2010

SQL Server 2008 Linked Servers

2005
http://www.sqlmusings.com/2009/03/11/resolving-a-network-related-or-instance-specific-error-occurred-while-establishing-a-connection-to-sql-server/

2008
http://mssqltips.com/tip.asp?tip=1673

Linked Server

EXEC sp_addlinkedserver
'J9gfrb101',
N'SQL Server'

Schema Syntax

SELECT COUNT (*)

FROM INFORMATION_SCHEMA.TABLES AS t

WHERE t.TABLE_TYPE = 'BASE TABLE'

AND t.TABLE_CATALOG = 'foo'

Thursday, May 6, 2010

DIR All

DIR /S - all files w/ subs, grouped

DIR /S /B - all files w/ subs, listed

Tuesday, May 4, 2010

MSC Commands from the Command Line i.e. AD Users

Thanks to Mitch Tulloch www.mtit.com/mitch/ and his link to :

http://www.windowsnetworking.com/kbase/WindowsTips/Windows2003/AdminTips/Admin/LaunchAdminToolsfromtheCommandLine.html

AD Domains and Trusts
domain.msc

Active Directory Management
admgmt.msc

AD Sites and Serrvices
dssite.msc

AD Users and COmputers
dsa.msc

ADSI Edit
adsiedit.msc

Authorization manager
azman.msc

Certification Authority Management
certsrv.msc

Certificate Templates
certtmpl.msc

Cluster Administrator
cluadmin.exe

Computer Management
compmgmt.msc

Component Services
comexp.msc

Configure Your Server
cys.exe

Device Manager
devmgmt.msc

DHCP Managment
dhcpmgmt.msc

Disk Defragmenter
dfrg.msc

Disk Manager
diskmgmt.msc

Distributed File System
dfsgui.msc

DNS Managment
dnsmgmt.msc

Event Viewer
eventvwr.msc

Indexing Service Management
ciadv.msc

IP Address Manage
ipaddrmgmt.msc

Licensing Manager
llsmgr.exe

Local Certificates Management
certmgr.msc

Local Group Policy Editor
gpedit.msc

Local Security Settings Manager
secpol.msc

Local Users and Groups Manager
lusrmgr.msc

Network Load balancing
nlbmgr.exe

Performance Montior
perfmon.msc

PKI Viewer
pkiview.msc

Public Key Managment
pkmgmt.msc

QoS Control Management
acssnap.msc

Remote Desktops
tsmmc.msc

Remote Storage Administration
rsadmin.msc

Removable Storage
ntmsmgr.msc

Removalbe Storage Operator Requests
ntmsoprq.msc

Routing and Remote Access Manager
rrasmgmt.msc

Resultant Set of Policy
rsop.msc

Schema management
schmmgmt.msc

Services Management
services.msc

Shared Folders
fsmgmt.msc

SID Security Migration
sidwalk.msc

Telephony Management
tapimgmt.msc

Terminal Server Configuration
tscc.msc

Terminal Server Licensing
licmgr.exe

Terminal Server Manager
tsadmin.exe

UDDI Services Managment
uddi.msc

Windows Mangement Instumentation
wmimgmt.msc

WINS Server manager
winsmgmt.msc

Monday, May 3, 2010

logMe

namespace Util
{
public class util
{
public static void logMe(string msg, string usr, string fPath)
{
try
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter(fPath, true))
{
DateTime dNow = DateTime.Now;
file.WriteLine(dNow + " | " + usr + " | " + msg);
}
}
catch (Exception ex)
{
Debug.WriteLine (ex.ToString());
throw;
}
}
}
}