Solved

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

Posted on 2009-04-08
5
329 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
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:udayakumarlm
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
best counters for cpu high usage 3 33
Webservices in T-SQL 3 31
SQL invalid column name 5 13
Help to build a Proc... 6 20
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

809 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