Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved in your SSC briefcase from the favorites tab.
Download now (direct download link)

Delimited String Parsing Functions - TwoCol set

By Jesse Roberge,

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.

Total article views: 2123 | Views in the last 30 days: 6
 
Related Articles
FORUM

Arrays in SQL SERVER

Arrays

FORUM

Arrays

Array query?

FORUM

Advice for array oflarge arrays

how would you represent an array of 1020 floats in record

FORUM

SSIS Licensing Question

Licensing

FORUM

SQL Server 2000 and 2005 licensing

licensing

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

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones