?
Solved

how to get the multiple substring which is having more than 8000 chars

Posted on 2009-04-08
5
Medium Priority
?
359 Views
Last Modified: 2012-06-27
I want to get use the substring like this. is it any better way to get the substring seperation of a column. i using SQL 2000
thanks in advance
select 
    @p_data1 = SUBSTRING(dv.data, 1, 8000),
    @p_data2 = SUBSTRING(dv.data, 8001 ,10000),
     @p_data3 = SUBSTRING(dv.data, 10001, upto end of the text(16013)),
from
  confirmation l (nolock)
  join version dv (nolock)

Open in new window

0
Comment
Question by:renjitkumar
[X]
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
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:udaya kumar laligondla
ID: 24095244
no other way is possible as you are using three variables and three ranges. SQL has to check for each range of substring. multiple value return is not possible in substring funciton.
0
 

Author Comment

by:renjitkumar
ID: 24095723
If i try in that way also i'm getting error "Expression result length exceeds the maximum. 8000 max, 16097 found." when i'm trying to take the value from 8000+.
Ex. if i want to get the data from 8001 to 9000 that time i'm getting this error message.
0
 
LVL 12

Expert Comment

by:udaya kumar laligondla
ID: 24095916
what is the field type of dv.data. post the full query
0
 

Author Comment

by:renjitkumar
ID: 24096002
declare @doc_handle int
declare @p_data1 varchar(8000)
declare @p_data2 varchar(8000)
declare @p_data3 varchar(8000)

select
    @p_data1 = SUBSTRING(dv.data, 1, 8000),
     @p_data2 = SUBSTRING(dv.data, 8001 ,10000),
     @p_data3 = SUBSTRING(dv.data, 10001,16097)
from
  confirmation_log dcl (nolock)
  join version dv (nolock)
    on dv.document_id = dcl.document_id

exec sp_xml_preparedocument @doc_handle OUTPUT, @p_data1 +@p_data2 + @p_data3


this is my complete query.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 1500 total points
ID: 24096812
Try it this way:

select
    @p_data1 = SUBSTRING(dv.data, 1, 8000),
    @p_data2 = SUBSTRING(dv.data, 8001 , 8000),
     @p_data3 = SUBSTRING(dv.data, 16001, 8000)
from
  confirmation l (nolock)
  join version dv (nolock)
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

770 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