Home Forums SQL Server 2008 T-SQL (SS2K8) Help required to extra image from varbinary column and create image on file system RE: Help required to extra image from varbinary column and create image on file system

  • Sean Lange (9/21/2011)


    Well then as Lowell said you can't do this with sql alone. This is more Lowell's expertise than mine but that is going to be pretty painful. You are going to have to try to determine what filetype it is by the contents. YUCK!!! What are you going to do when they ask for a new filetype? Seems that without the full original filename or at least the filetype you are in for a long and possibly impossible battle. This could prove to be a very interesting thread to follow to see what others have to say.

    I'm probably being very simplistic \ ignorant in my outlook here, so please bare with me as I've never had to do anything like this before... Why can I just write the output to a file with a JPG format then try manually opening the file using a graphics package. If the file opens and renders correctly then it was a JPG file so I can proceed on that basis. If not then I adjust my code to create a file with a GIF extension then repeat the process until I get the correct format.

    Once I get it to open I'm good to go as I know the format gerenated by the external system won't change.

    Thanks.