types - Create data for Image column in SQL Server -


i need create data test limit of image datatype in sql server. able hold variable-length binary data 0 through 2^31-1 (2,147,483,647) bytes. using following directly in sql server:

insert employees (id, name, photo)  select 10, 'john', bulkcolumn openrowset( bulk 'e:\photo.jpeg', single_blob) employeepicture 

my question is, how ensure max size (2,147,483,647 bytes) being inserted column? find image of size 2g , insert column? there way this?

thanks in advance.

most jpeg viewers ignore bytes after image data. following code tack on enough bytes make file whatever size want. tested , resulting image opened in windows image viewer, paint.net, , photoshop. should able create test files it...

    long desiredsize = 200000;     byte[] buffer = new byte[1];     string filename = @"c:\temp\sample.jpg";     using (var fs = new filestream(filename, filemode.open, fileaccess.readwrite))     {         fs.seek(desiredsize - fs.length - 1, seekorigin.end);         fs.write(buffer, 0, 1);         fs.close();     } 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -