Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to concatenate strings

Posted on 2002-04-15
5
945 Views
Last Modified: 2008-03-06
Hello!

I'm working on a program that extracts data from one database to another.
In several places, some text fields have to be concatenated. For instance, There are 6 addresses lines to be stored into 3 lines. This example would be easy, but there are more complicated issues: 9 text lines have to be stored into 4 text fields.
I was thinking about a general stored procedure that could look like this:

ConcatenateFields @AllTheValues, @FieldNumber, @FieldLength, @result

This function should return the substring of @AllTheValues, starting at @FieldLength * @FieldNumber

The problem is that the @AllTheValues parameter could be a string > 255. Also, I thought of declaring as Text, but I'm not allowed to do so, like its not allowed to declare a local variable of type text.

Does anyone have an idea on how to implement such a function? How can I use large strings in a stored procedure? Any ideas?

Thanks.
0
Comment
Question by:ornicar
5 Comments
 
LVL 5

Expert Comment

by:amitpagarwal
ID: 6943046
the best way to handle this would be while extracting data at the first step - use OS string commands to get your results.
0
 
LVL 3

Expert Comment

by:ahoor
ID: 6996907
From Sybase 12.5 you can use bigger varchars... upto 16K if you set the pagesize (serversetting) high enough.
However if you would do this you may want to build a temporary 12.5 server which has 16K pages for this conversion, so you won't have to change any servers you use.
0
 
LVL 10

Expert Comment

by:bret
ID: 7025013
Even with a 2K page size, an ASE 12.5 server can have char/varchar columns up to ~1950 bytes in length.
0
 
LVL 6

Expert Comment

by:ChrisKing
ID: 9947803
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ/No Refund

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

ChrisKing
EE Cleanup Volunteer
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 9990070
PAQed - no points refunded (of 200)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are looking at this article, you have most likely been hit by some version of ransomware and are trying to find out if there is anything you can do, or what way you should react - READ ON!
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question