Solved

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

Posted on 2009-04-08
5
351 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 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

728 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