Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
244 views
in Technique[技术] by (71.8m points)

SQL Server truncation and 8192 limitation

In SQL Server 2005 I am trying to query a varchar(MAX) column which has some rows with text data that exceed the 8192. Yet, In Management Studio I have under Tools --> Options --> Query Results --> Results to Text --> Max numbers of characters displayed in each column = 8192, which is a maximum. Accordingly, it seems the truncation on these rows occurs only due to the limitation imposed by text output.

The only thing I see to get around this is to use a SUBSTRING function to grab say the first 8000 chars, then the next 8000 chars etc. etc. But this is ugly and error prone.

I should mention that SSIS and BCP are not options for me.

Does anyone have a better suggestion? Thanks!

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can export the data to a flat file which will not be truncated. To do this:

  1. Right click the Database
  2. Click Tasks -> Export Data
  3. Select your Data Source (defaults should be fine)
  4. Choose "Flat File Destination" for the Destination type.
  5. Pick a file name for the output.
  6. On the "Specify Table Copy or Query", choose "Write a query to specify the data to transfer"
  7. Paste in your query

Remaining steps should be self explanatory. This will output the file to text and you can open it in your favorite text editor.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...