Question

Locked

SQL 2005 - Export binary fields to JPG

By giuliano.foletto ·
Hi

I have a database with lots of JPEG images archived there and would like to export to disk naming each file with the ProductID column that is in the same table. I found couple of things in the Internet but I couldn't manage to do it.

Does anyone have a solution for that?

Here you can see two examples, the number is the ProductID column and the rest is the binary column:

1355954 0xFFD8FFE000104A46494600010101012C012C0000FFDB0043000604040405040605050609060506090B080606080B0C0A0A0B0A0A0C100C0C0C0C0C0C100C0E0F100F0E0C1313141413131C1B1B1B1C20202020202020202020FFDB0043010707070D0C0D181010181A1511151A20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020FFC00011080055005503011100021101031101FFC4001C0000020203010100000000000000000000050604070001030802FFC4003B100002010205010506020A0105000000000102030411000506122131071322416114233242517181A10815243352627291B1C1D1536382B2D2FFC40017010101010100000000000000000000000000010203FFC400201101010100010305010000000000000000000111023171C10312214161F0FFDA000C03010002110311003F00F54E03301A2C07FC60177586A7391D077CAF0A4CD7114723004F1D47A83E8712D148675AF3B40CC7728CF9E9E1DC595695444C3D372246481FD589A00B66BAF95F743AA336671F29A89C8FC4194FF8C3415A6ED77B59CAA4DD2E614D99C60730D6C091A80B7F9D0533127FACE1A2C0D29FA43E9FAEA85A0D4F48FA7ABC909DEC87BCA524DADBA4B234573FC6BB40F9B1745B114B14D124B0BAC91480347221DCACA790411C107147DE033019808D5398D253CAB0C922ACAC376D27A2FD4E1A2B6D63DACF72EF41A76D34A2E24AFB6F00FF00DA5F9BEFD3D319D08F97E439CE739933E6D23999DC157BC92978D95B697664013946E2FE439E40C40E741D9F64F4F0A46F177BB5765E4F192BD0825AE4DEDCDFAE09AE145A3E64CE657AA8524A278DFC5B20E5D6A9DA1DC40592E9114DBE439BDCF38A68855692CAE50C0C2086E4FF006B621A44D43D9DD39DC91C61A045F135C051237CAA2E594F20E0A1BA5759EA7ECEABE385CC99869776DB3D1372D0DCF2D09360AC09FE96F3B1E4583D1F9466D97E6F96D3E65974C2A28AA977C32AF98FB75041E083D0E34266005EA6D4145A7B22ACCE2B4FB8A48CBED1D5DBA220F56620603CE4752E7F9E4B51985648CD2D73165893A2C67A2A8FA58003D3180F5A4345C5184ACAC40D3F3B091C8527A7E42F821E22A6811B72A0DD602FE82F6FF27151DF01A2301C996F808AF4D12F7840E643B9FD4D82FF008518047D5191D32A35D3743213B836E73791BD6E6DCFE1F6C469AECBB53D3697CCD74FD549B32FCC24FD9DDC9B2CADC0F4E7807160BC71A144FE911A965A8CDB28D1D035A3947B6D7DB69E2E5631F5BA84736F5189440D13A7296BAAA39E68C3251B5E2B7C8DB0AFE1E07FCF190F3A6B2DCFF2BCB4A66B5BFAC270AA372DF920B5DF902DE12ABB471E1DDD58E2B21DA4FB4AC9B3DCC2AF2B225A0CE685CAD4E575802542A8360E002CAEA78E5091CFA8C170E6AE08C1106963CD8665532544C1A8580F678AEA6C6E79B08D08E2DD5DBF0C475E5787B6675FEFD4C660315C81F3ACFF002CCAE964A9AEA88E9E04F8A4958228BF4B96B0C149B555D9EE79554F3A53CB97E428B2F7C6A008A7AADCA563EEA020CD1AAB78B73F767F948E7114B79E64E2AE9A28C02B240C3BB69396DB7DBC9E6F71CE03D09A52BAA2B74FD14D52DBAABBA559DBCCBA8F88F0A2EDD4D8637079AF59D57EB6ED9F3FAA176869985245BB9DAD0AA42E07D06E4738CD16CE8FA45A7CAD0F376B9248B7FC6225168A4ADAB9524A69624A3045CD8BBBD8BABA11E1DBF2F3D41B823150035D7661926AA54A9BBE5F9E5378A8737A63B2789C74E45AE3D3052DE43ABF5964198B641ACE90C8F126FA6CFE997F66A88D485BC807EE9FC42FE5D7A5B00E54FAAA8E6E55C11E841C4301E6D559C6747BAD3D4C0529255B39AB0CB4FC1B1EE231B64A9F4D968CFF00D4071474A1D0F2C6CB98C927B7E7B1A9EE330CC3C5DDB38B37710A5A3A707A7806E23E26381A3D0C288F245347B6525BBB662A4C8A00F1000B1F3B73F4C022EA082383309C22A2349E3247C4CD6DB73F60145F11569F6775693E43185284AAA9976F5DED7EBFF8EDC6B88A527C9BBACF351E64FD67CFEA11479DBBFAA3F9D86321FB29CA2531F782B260AF47ECA226DA6CC493DF1600B6EE6C2C6DF7F2A94582E615D96352D3544B974C5761AC9043254AF36DCA83745B88DD62C2C0FCA7041CB5F9C007D4D937EB1A178B8E5580BF95C5B058AEB2CC9330A2CDBBB91363C042BAF5B9F897A7DC1C455A74397470C4AC417948E5DB938ACB59AD0D5D5D27734B5D2E5D2EE53ED30244EFB41E5409D254E4717DB801F502319C411DE47996190B39562B6257AB2911AB74F96FF4F3C05759DA6650CDB6B6759245EF77AA827E29498BC764F863F091B711A307E8E955DED367CBB8B6D7A73CFF00377BC7E58B043D7B04D45AAF3CA6645582AFB9CC68C2F038451231E82E5A398FE38507B4E555E94EFDA918F146779625080C59AE06DF19616048B0FC044A3F053533BAD4C7E16661233466C24F0151BADF1707F21F4C54124180DCA974B60A1343448F9C665230BEDAB16BFD3D929FFDE23AFA93E276F3477BBC57144AEA46A880C4B33C0C7A4919B30FEF7C04014305140DB0B3B5BC534A77C840E9B98F26C38E701526B4CC7DED5C8A7E10420E2D7F4F3E49B6234B0BF47EC81B2BD0E6A655F7D995434DBFCCC6A02283F8AB7F7C6A09DDAE69D9AB7288F37A35BD665B72E00BEE81BE2F2B9DA45FED7C28AFF2197F59652F42EFDDC4E924354A155D9A392365B0DF71705AFCA907E9CE322C6C929969B2FA7A48C968E9E348919AD72105813B428F2F216C5646E289FF008701CA5A6CDB9D9342016F777858D85FCFDEF3C7DB0545A0A6CCFDBABD94C5E2AA24DD1BA0A78556DE2F437C1D79F49DBCD17863A9B7BE0B7FE4BFFBF4C5C727C4CA40E988849D67552D287AC8253ED2B0B43040FF00B9BB1DC58D94B7361E7E5F7B962B7A0C9EAF5366B1D1C20912C9627CADD493E83115E8DCB6829F2ECBE9E869976C14D1AC718F4516C6C4874574647019185994F208380A7F5568DAAD3998B66596217CBE46B941F2DFE43FE8E3025E43A8536064F1C6481DDA801958B78CB6E20717B91D7EFD300DD93E6FED92CCE8C8D44968E1914862D229225E5598581B258804306F4C6906F7A9B62AB8D114EF27E79EF9AFFD87FAC46B97D253C8A062B057A8D5104797453549DB3BDD5D024ABB5C5CD889155D45870580BF1F5189424FB0E73AB2A5CC2A63A143FB454725777F0477F89BFC753E40E5561E8FD21499141BC2FED2E36DFF00857E97FA9F3C6A40C98A3301F12C514D1B472A878DC5995B904601133FECE3DEB5664D277331EA9D7F023E61F9FAE318171EAF3FCAD8C7574F347B41513C00B817F3D9626FE7CA90300421ED0698787BD432022E85AC473CFD79B603950EB3A1CBBDA0FBB896A2AA5A8936BDC7BCE7758227898F51F7F11C52B526B7AECDAF4D95D3CB532480A1684102E7CF78F87EF7C44C15CA7B399EAEA1ABB3F907BF3BE4A3A7F0EF6B0506594589B2ADB8F4E71AC53ED3D2D3D34290C11AC51462D1C6800551E80628EB80CC06603301980E72C10CC2D2A071E571801D53A6323A9169A951FF00A806FF00DAF89838C7A2F4D46DB92820523CC451FF00F3860290D0D2C22D1C605B0C1DF146603301980FFFD9

1355955 0xFFD8FFE000104A46494600010101004800480000FFDB0043000604040405040605050609060506090B080606080B0C0A0A0B0A0A0C100C0C0C0C0C0C100C0E0F100F0E0C1313141413131C1B1B1B1C20202020202020202020FFDB0043010707070D0C0D181010181A1511151A20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020FFC00011080055005503011100021101031101FFC4001B00000203010101000000000000000000000005020304010608FFC4003A1000010302030407050509000000000000010002030411051221061331511422323341618107527191B142437292D123245362A1A2C1C2E1FFC4001801010101010100000000000000000000000001020304FFC4001F1101010002020300030000000000000000000102111231031321415171FFDA000C03010002110311003F00FAA500804020100804020100804192BF17C2F0FCBD3AAE2A62F04B1B23C34B8378E507536BF8205B45B6DB395D5AFA3A3A9DF4CC6E721A0F01C6C0D9C78F1B595D2725957B5B82D2F7B358FBBE3F2578B3EC85337B4BC0E3E01EFF008057833ED663ED5708BF7122703DAB62F6A381BCF59AF6FA2703D8654BB75B3F51D99F29E4ED14E2D7B0E29710A4AAEE5F7BEA3FE2CE9A95A514201079DDA2D90A0C4A496B990B0D7C91B6195E475A4898491187F699AB8F0363E2A582AD98A465351F46A6063A480648E0F75D725DABAEEF4BAB82666B352504A2D52C649F8DA0FD56DCCAAA302D997937A58BD039BF4B2BB4D4643B33B2BC7A3FF7BFF54DA69747B37B223EE35FC4FF00D53669A5F45B2187C3D2258218E21619DE0BB53C38DD45328C524B135D0E910ECE5196D6E492AA9E8F8D484B9B55232376AC6DA1D07E47159F8DFD069B1082D34D572BD8D23300E8F9F2DD8BA1F4D584968278A8D4490667C6C63CE516CFD636E7E2558C64C950B48565C5C0DC6520DACA4A8A5CAA3AC44538E42C9B0CDD3F56BDEDD3D514EE87AB878F559C7A5A6ED16681C828EA5F89CA649E0A26769E7792F931BC3E6E56339180160028D3A830E2D3BA9E0DF017B5DB6F3770FEAA6596A258CD576DD59E6DA6AAE5D7D6212D344F6BE679738B5C7AB75CFC18D9BBF7EB59D4CAEEE6931111C485E0887F384538A51FBA44DF78FD4ACE3D2D6FADAC868E99F5131B3183C3893E007993A051D6D64C1E9A621F5D542D5353D62DF71BF65A3E015ACE264A341064C529C4F45230F9387A1BA966C219EAA631C7BC6D9BA8CBF036B5BC9797C9E5B35BE971C54C54E6391EF06D1BFB2DFF002BBF87C5C6DFD5633CB6EB977727588235EEEE1BCDD7F9297A5875485AD653E6366B467713C2CD175274D7E54C4D763158DA97E987539BD330FDB77F10FF00AABD2F7FC3B596C201045EC0E639A783858FAA0F235389C94D33A88B448F678916F8E812B1A6A758C6D2D16046816E32CEE46528F8A0A6B3AD5713390FAACE7D350D67C3BA7490C47B98F593CC722B49AD9DC71B636063059ADD0058764900804020F3DB450D5455305452C6D7677649C65BB88D3E96466B932DB9B2391128C20A61FDAE28E3E0D207E559BDB4F594D16EE200F68EAE52BA48B5142010080419EB403079DC65F8AB1294D4432B45CB74E6B4E6C0E20144483C36373ED7CA2FA222CD9CA7267DE4C2CE76A01F3D565B8F4EA3A040201008041C2D0E163A8414C94A1ED2DCEE00ABB4E2CAEC1A33F787E41369C538F0A8D808DE3B5E36B26CE0BE9A8A0A7D5972E3C5EE372A2E97A284020100804020100804020100804020FFD9


Thanks a lot

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

You are going to have to write some code

by Tony Hopkinson In reply to SQL 2005 - Export binary ...

Plenty of examples on google
Search for loading and saving images to databases.

Basically you pull the blob field out of the database into a stream and than save it as a file which would be ProductID.jpg.

If you have no devlopment environment Visual Studio Express would be an option.

Back to Networks Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums