Microsoft Most Valuable Professional

Chris Pietschmann

An MVP From Wisconsin

The My namespace in Visual Basic 2005 is extensible!

Yes, that's right. You can add your own custom functionality to the My namespace. Microsoft has even created a My.Blogs library that adds functionality for read and writing to blogs. And, there is an MSDN TV episode that explains how to use My.Blogs.

Simplify Common Tasks by Customizing the My Namespace
http://msdn.microsoft.com/msdnmag/issues/05/07/My/

My.Blogs Code Sample for Visual Basic
http://msdn.microsoft.com/VBasic/Downloads/Code/MyBlogs/

MSDN TV: Adding Blogging to Your Apps with My.Blogs and Visual Basic 2005
http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20060126VBasicCM/manifest.xml

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General
Posted by crpietschmann on Friday, February 10, 2006 11:10 AM
Permalink | Comments (0) | Post RSSRSS comment feed


T-SQL: Parse a delimited string

Parsing a delimeted string in T-SQL is fairly simple to do, but it does take a nice little chunk of code. I most commonly use this chunk of code when I need to pass an array from an application into a SQL Stored Procedure. The best way to implement this code into an application would be to create a SQL Function that you pass in a delimted string and it returns a table of values. This way you don't have to duplicate the code everytime you want to use it.

The following example parses the delimeted string and places each value into a variable of type Table. Once the values are placed into the table you can do anything you need to save/process these values.

--declare the list of Cities
DECLARE @CityList varchar(8000)
SET @CityList = 'Milwaukee|Chicago|New York|Seattle|San Francisco'

--declare the delimeter between each City
DECLARE @Delimeter char(1)
SET @Delimeter = '|'

--Parse the string and insert each city into the @tblCity table
DECLARE @tblCity TABLE(City varchar(50))
DECLARE @City varchar(50)
DECLARE @StartPos int, @Length int
WHILE
LEN(@CityList) > 0
  BEGIN
    SET @StartPos = CHARINDEX(@Delimeter, @CityList)
    IF @StartPos < 0 SET @StartPos = 0
    SET @Length = LEN(@CityList) - @StartPos - 1
    IF @Length < 0 SET @Length = 0
    IF @StartPos > 0
      BEGIN
        SET @City = SUBSTRING(@CityList, 1, @StartPos - 1)
        SET @CityList = SUBSTRING(@CityList, @StartPos + 1, LEN(@CityList) - @StartPos)
      END
    ELSE
      BEGIN
        SET @City = @CityList
        SET @CityList = ''
      END
    INSERT @tblCity (City) VALUES(@City)
END

--Show all Cities in the @tblCity table
SELECT * FROM @tblCity

 

Currently rated 2.5 by 2 people

  • Currently 2.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: General
Posted by crpietschmann on Friday, February 03, 2006 10:53 AM
Permalink | Comments (1) | Post RSSRSS comment feed


About the author

I'm Chris Pietschmann, go to the About Me page to learn more about me.

Search

Sponsors

Web.Maps.VE - ASP.NET AJAX Virtual Earth Mapping Server Control

Recent comments

Disclaimer


This work is licensed under a Creative Commons Attribution 3.0 United States License, unless explicitly stated otherwise within the posted content.
© Copyright 2004 - 2008 Chris Pietschmann