Solved

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

Posted on 2009-04-08
5
313 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
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:udayakumarlm
Comment Utility
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
Comment Utility
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:udayakumarlm
Comment Utility
what is the field type of dv.data. post the full query
0
 

Author Comment

by:renjitkumar
Comment Utility
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
Comment Utility
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now