SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Delimited String Parsing Functions - TwoCol set

By Jesse Roberge, 2008/11/03

Total article views: 1832 | Views in the last 30 days: 14

Delimited String Parsing Functions - TwoCol set
by Jesse Roberge - YeshuaAgapao@gmail.com

Feed it two-column delimited horizontal data and it returns it back as a vertical table with the two column data in the same synchronized position order
Requires a table of numbers. These functions expect it to be called 'Counter' in the same database that you save these functions to.
Search for 'Counter table (table of numbers) setter-upper for SQL Server 2005' or Counter table (table of numbers) setter-upper for SQL Server 2000' if you need a script to set this up for you.
Works in both SQL Server 2000 and 2005.

Variants:
Array Has array position index and value data is not casted.
Table No array position index and value data is not casted.
IntArray Has array position index and value data is casted to int.
IntTable No array position index and value data is casted to int.
In the TwoCol delimiter function set, the table variants have negilable performance gain over the array variants because the position indexes is needed internally.

Usage:
fn_DelimitToArray_TwoCol ('red,green,yellow,blue,orange,purple','square,rectangle,circle,triangle,oval,hexagon',',',',') AS ParameterTable JOIN [table] ON ParameterTable.Value1=[table].[any decimal/numeric/character field #1] AND ParameterTable.Value2=[table].[any decimal/numeric/character field #2]
fn_DelimitToIntArray_TwoCol ('1,2,3,4,5,6','11,22,33,44,55,66',',',',') AS ParameterTable JOIN [table] ON ParameterTable.PK_IntID1=[table].[int field #1] AND ParameterTable.PK_IntID2=[table].[int field #2]
fn_DelimitToIntTable_TwoCol ('1,2,3,4,5,6','11,22,33,44,55,66',',',',') AS ParameterTable JOIN [table] ON ParameterTable.PK_IntID1=[table].[int field #1] AND ParameterTable.PK_IntID2=[table].[int field #2]
fn_DelimitToTable_TwoCol ('red,green,yellow,blue,orange,purple','square,rectangle,circle,triangle,oval,hexagon',',',',') AS ParameterTable JOIN [table] ON ParameterTable.Value1=[table].[any decimal/numeric/character field #1] AND ParameterTable.Value2=[table].[any decimal/numeric/character field #2]

Copyright:
Licensed under the L-GPL - a weak copyleft license - you are permitted to use this as a component of a proprietary database and call this from proprietary software.
Copyleft lets you do anything you want except plagarize, conceal the source, or prohibit copying & re-distribution of this script/proc.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

see <http://www.fsf.org/licensing/licenses/lgpl.html> for the license text.

By Jesse Roberge, 2008/11/03

Total article views: 1832 | Views in the last 30 days: 14
Your response
 
 
Related Articles
FORUM
FORUM

Arrays

Array query?

FORUM

Advice for array oflarge arrays

how would you represent an array of 1020 floats in record

FORUM
Tags
advanced querying    
arrays    
counter    
delimited strings    
development    
nums    
parse    
sql server 2005    
sql server 7, 2000    
sqlinsider scripts    
string manipulation    
table of numbers    
tally    
t-sql    
t-sql aids    
 
Contribute

Free registration required...

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Login (existing users)

Login

Email:   Password:   Remember me: Forgotten your password?

Register (new users)

Register

Email:   Password:
Confirm:

Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

Steve Jones
Editor, SQLServerCentral.com