Split CSV String into Table in SQL Server

Date April 5, 2010

By default there is no function in SQL Server that can split comma separated string into Table (Rows). Following t-sql is custom made function that can split csv string into table.

CREATE FUNCTION dbo.SplitCSV (@CSVString VARCHAR(8000), @Delimiter CHAR(1))
RETURNS @temptable TABLE (items VARCHAR(8000))
AS
BEGIN
	DECLARE @pos INT;
	DECLARE @slice VARCHAR(8000);

	SELECT @pos = 1;
	IF LEN(@CSVString) < 1 OR @CSVString IS NULL RETURN;

	WHILE @pos!= 0
	BEGIN
		SET @pos = CHARINDEX(@Delimiter,@CSVString);
		IF @pos != 0
			SET @slice = LEFT(@CSVString, @pos - 1);
		ELSE
			SET @slice = @CSVString;

		IF( LEN(@slice) > 0)
			INSERT INTO @temptable(Items) VALUES (@slice);

		SET @CSVString = RIGHT(@CSVString, LEN(@CSVString) - @pos);
		IF LEN(@CSVString) = 0 BREAK;
	END
	RETURN
END

Usage:

SELECT * FROM dbo.SplitCSV ('Computer,Keyboard,Mouse,USB', ',');

Tooltip using CSS

Date March 31, 2010

Do you want to have custom tooltip without using JavaScript in your website? Using following code you will have custom tooltip in your website.


Now use following HTML code that will generate custom tooltip on link.

This is Custom Tooltip Custom Tooltip.

Inner <SPAN> html tag in <A> is using for tooltip text. By default this text is hidden popped up when user move mouse on Link.

Example:
This is Custom Tooltip Custom Tooltip.

Data Mining in SQL Server 2008

Date March 30, 2010

Microsoft SQL Server 2008 empowers informed decisions with predictive analysis through intuitive data mining ─ seamlessly integrated within the Microsoft Business Intelligence platform and extensible into business applications.

Top New Features

  • Test multiple data mining models simultaneously with statistical scores of error and accuracy and confirm their stability with cross validation.
  • Build multiple, incompatible mining models within a single structure; apply model analysis over filtered data; query against structure data to present complete information, all enabled by enhanced mining structures.
  • Combine the best of both worlds by blending optimized near-term predictions (ARTXP) and stable long-term predictions (ARIMA) with Better Time Series Support
  • Discover the relationship between items that are frequently purchased together by using Shopping Basket Analysis; generate interactive forms for scoring new cases with Predictive Calculator, delivered with Microsoft SQL Server 2008 Data Mining Add-ins for Office 2007.

Google Transliteration

Date March 10, 2010

Google Transliteration allows you to type phonetically using roman characters. Simply type a word the way it sounds in English and Google Transliteration will convert it to its local script. We currently support 19 languages: Amharic, Arabic, Bengali, Greek, Gujarati, Hindi, Kannada, Malayalam, Marathi, Nepali, Persian, Russian, Sanskrit, Serbian, Punjabi, Tamil, Telugu, Tigrinya and Urdu.

Example:
http://www.google.com/transliterate/

Subscribe to Technology Tips

Subscribe to Saqib-Ansari via RSS

Or, subscribe via email: