From: Miguel Mendes Date: 2012-12-22T02:42:55+09:00 Subject: Tinytds - Save binary as file Hello, I'm learning Ruby and I'm trying to save to disk some content that is in sql server in a column of type 'Image'. Problem is that the column with the content always have the same size(4096) whem I'm iterating through the results. My code so far: client = TinyTds::Client.new(:username => 'someuser', :password => 'somepass', :dataserver => 'someserver', :database => 'somedb') result = client.execute("SELECT top 5 Content,DirName,LeafName FROM sometable where ListID='819B' AND Content is not null") result.each do |row| directory_name = File.join("d:" , row["DirName"]) FileUtils.mkdir_p(directory_name) unless File.exists?(directory_name) filename = File.join(directory_name , row["LeafName"]) p row["Content"].length # Always returns 4096... File.open(filename, "w") do |myfile| myfile.write(row["Content"]) end end -- Posted via http://www.ruby-forum.com/.