This user-defined function (only available in SQL 2000 and above) is part of a larger project I'm working on. PARSENAME in SQL Server is my new favorite function.. Thanks to Jeff Smith for the heads up. CREATE FUNCTION [dbo].[IPtoNumeric] (@strIP varchar(255)) RETURNS bigint AS BEGIN DECLARE @intIPNum bigint IF …
Read MoreI keep track of all hits to my website RealCajunRecipes.com in a SQL table called hitcounter which has columns for the user's IP, browser, referring URL and the date. Recently, I saw a surge in traffic and wanted to know which domains were sending the traffic our way. After getting tired of issuing ad-hoc queries that …
Read MoreThis isn't a very common scenario, but I figured I'd write about it anyway. We recently implemented a Windows 2003 Active Directory domain at work. I suggested to my employer that, going forward, we only install SQL Server 2005 when we need a database server (phasing out 2000). I'd also suggested consolidating a couple …
Read MoreUsing SQL and want to know how many times 'http' appears in a string using about one line of code? Find out by creatively using the replace() function. Declare @myStr varchar(1500), @countStr varchar(100) Set @myStr = 'https://www.buydrugshere.com go here! https://www.onlinemortage.com right there!' Set @countStr = …
Read MoreThis is a barebones script that gathers server events across a domain and stores them in SQL Server using asyncronous notifications as seen in this sample of the code: strWQL = "Select * from __InstanceCreationEvent where TargetInstance isa 'Win32_NTLogEvent'" objWMIService.ExecNotificationQueryAsync …
Read More