I'd like to start this post by saying that BCP is limited and ghe-toe, but it gets the job done to some degree. One of the guys over at SQLteam.com wrote a really informative post on Flat File Bulk Import methods speed comparison in SQL Server 2005 that you should check out if you are into that sort of thing. BCP ranks …
Read MoreInspired by kitty0's GeoIP Demo, I created two scripts which automatically import the free MaxMind GeoIP database (which resolves IP addresses to city locations) into SQL Server using VBS and BCP. The VBS file can be set as a Scheduled Task for MaxMind's free once-a-month updates. I also created a SQL Server UDF to …
Read MoreThis 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