Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 unable to see full file content when i give select

Author  Topic 

fresher1234
Starting Member

6 Posts

Posted - 2010-11-03 : 01:00:56
I uploaded a unformatted txt file from Java program to sql server.
On the DB side i gave select cast(filecontent as varchar) from attachment;
(filecontent is columnname which has the uploaded file contents with varbinary(max) datatype)

when i execute the above statement i see only few chars of file.Not the entire file
Thanks,

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-03 : 09:14:24
you need to specify the length when casting to varchar

select cast(filecontent as varchar(max)) from attachment;

Also see what happens when you dont specify length
http://beyondrelational.com/blogs/madhivanan/archive/2007/12/04/column-length-and-data-length.aspx


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2010-11-03 : 09:50:35
You may also want to adjust your "Maximum Characters displayed in each column" property of the Results page in your Query Options window.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -