title: Can you embed blob data in a script for sql server?
body: <p>I'm testing the retrieval of blobs by a web application.</p>
  
  <p>There are some difficulties uploading blobs programmatically from the javascript code so I decided to prepopulate the database with some data instead.  However I'm running into some problems with that aswell.</p>
  
  <p>We have a database versioning process that expects all the schema + data for the database to be in scripts that can be run by sqlcmd.</p>
  
  <p><a href="https://stackoverflow.com/questions/1643627/how-to-insert-a-blob-into-a-database-using-sql-server-management-studio">This post</a> seems to show how to insert blobs.  However this script requires that you specify an absolute path to a file on the server.</p>
  
  <p>Is there another way?  We are using source control and continuous integration and so wouldn't ever really want to refer to a file in a specific place outside a given copy of a repository on one machine.</p>
  
  <p>If not it seems like there are 2 options:</p>
  
  <p>Take the hit and never change or delete anything from a random directory on the database server aswell.  The data will need to be split between several locations.  Further more we either ban blobs from production config deployment or just have to bear in mind we have to do something crazy if we ever need them - we wont be in control of the directory structure on a remote server.  This probably wont be a massive problem to be fair - I can't see us wanting to ship any config in blob form really.</p>
  
  <p>or</p>
  
  <p>write a program that does something crazy like remotely create a temporary directory on the server and then copy the file there at the correct version and output a script with that filename in.</p>
  
  <p>It doesn't really seem like having things under source control and not wanting to hardcode paths is exactly an outlandish scenario but the poor quality of database tools stopped surprising me a while ago!  </p>