As you probably know, Microsoft provides two undocumented/unsupported stored procedures for iterating through databases, sp_msforeachdb and sp_msforeachtable. I've always wondered, then, why the following code never showed up in Google searches:
sp_MSforeachdb @command1 = 'EXEC sp_msForEachTable @COMMAND1= ''DBCC …
Read MoreThere are a few ways to do this but here's one that I like. I believe it works in SQL Server 7, 2000 and 2005.
ALTER DATABASE myDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO USE myDatabaseName GO
Go ahead and do what you need to do then set it back:
ALTER DATABASE myDatabaseName SET MULTI_USER
Read More- This is more of a post for proper keywords. My previous entry titled "Import MaxMind City CSVs into SQL Server 2005" assumes the user has already conducted research to find that MaxMind's free GeoIP database provides the functionality to look up the location of an IP address. So, if you wish to quickly and …
Read More - 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 More - Inspired 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 More - Earlier today, I pasted some code into a Linux-based vi via putty/ssh, saved it, zipped it, and downloaded it to a Windows machine. The result was pooh; the code ran but was garbled in notepad. I wondered if I could somehow run a command in Linux to clean/convert all the carriage returns. One of my friends at …
Read More 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 MoreWow, have ya'll seen the new Google Groups interface? It's sex on legs.
<img loading="lazy" decoding="async" alt="" class="image_figure image_internal image_unprocessed" …</picture></figure></a></p>
Read MoreUpdate: If you are an iTunes user that needs VBScript, this page won't help you. Please visit the following two sites for two different solutions: Apple Docs and KeathMilligan.net.
This is an old script I dug up which I call "fileFetch". It's a script that downloads a binary file using XMLHTTP and saves it …
Read More- I've used CDONTS for years, even though it hasn't been included in a Windows Server release since NT4. Anytime I needed to send mail, I'd copy over CDONTS.dll, register it then use my old CDONTS code. Not sure why I resisted it for so long.. I think the weird Configuration Fields were too odd to accept. But I've …
Read More