dbTalk Databases Forums  

Export the Data of a field of 5000 characters length

microsoft.public.sqlserver.clients microsoft.public.sqlserver.clients


Discuss Export the Data of a field of 5000 characters length in the microsoft.public.sqlserver.clients forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Muhammad Kashif Azeem
 
Posts: n/a

Default Export the Data of a field of 5000 characters length - 08-24-2007 , 06:21 AM






I have a table like that:
Create table myTable
( Name varchar,
Description Text )
The description column contains more than 300 characters. The sql limit is
to show only 30,35 words. Is there any tool available which can export
around 5000 characters or more data of a single column.
Regards




Reply With Quote
  #2  
Old   
Peter YangMSFT]
 
Posts: n/a

Default RE: Export the Data of a field of 5000 characters length - 08-26-2007 , 10:32 PM






Hello Muhammad,

I replied you in the microsoft.public.sqlserver.connect newsgroup, and I
have included the content here for your reference:
=========================================


The text length returned is limited by @TEXTSIZE option in a connection.
Also, client tool such as Query Analyzer in SQL 2000 has the limitation of
8K. You could use the following method to set the @TEXTSIZE to the maximum
value.

SELECT @@TEXTSIZE
SET TEXTSIZE 2147483647
SELECT @@TEXTSIZE

Please refer to TEXTSIZE in Books Online for more details.

You could set maximum text size returned by Query Analyzer in 2000 to 8000.

Tools->Options->Results->Maximum characters per columns.


If you use Osql and use Textptr to get the text, the limiation is about
25K.

SET TEXTSIZE 2147483647
DECLARE @ptrval varbinary(16)
SELECT @ptrval = TEXTPTR(pr_info)
FROM pub_info pr where pub_id = 0736
READTEXT pub_info.pr_info @ptrval 0 63357

The most simple method to work around the limiation is to use bcp utility
to export the result text to a file:

bcp "SELECT pr_info FROM pubs..pub_info where pub_id = 0736" queryout
pubsout.txt
-c -Sservername -Usa -Ppassword


Also, you could use SP and your own application such as VB or .Net code to
get the text directly. For example:


Create a stored procedure "Test":

===============
CREATE PROCEDURE Test
AS
BEGIN
SET NOCOUNT ON;
Select pr_info from pub_info where pub_id=0736;
END
GO

==============

Dim cn As ADODB.Connection
Dim strm As ADODB.Stream
Dim cmd As ADODB.Command
Set cn = New ADODB.Connection
cn.Open "Provider=SQLOLEDB;data Source=<server\instance>;Initial
Catalog=pubs;integrated security=sspi"
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = cn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "Test"
Set strm = New ADODB.Stream
strm.Open
cmd.Properties("Output Stream") = strm
cn.Execute "SET TEXTSIZE 200000"
cmd.Execute , , adExecuteStream
strm.SaveToFile "c:\pubinfo.txt", adSaveCreateOverWrite
cn.Close
==============


317034 HOW TO: Read and Write a File to and from a BLOB Column by Using
Chunking in
ADO.NET and Visual Basic .NET
http://support.microsoft.com/default...b;EN-US;317034


Also, in SQL 2005, you could set the "Maximum Characters Retrieved" to a
bigger value in Management Studio.


Hope this helps. If you have any further questions or comments, please feel
free to let's know. Thank you.


Best Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

================================================== ===


This posting is provided "AS IS" with no warranties, and confers no rights.





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.