Announcement

Collapse
No announcement yet.

How to insert binary data into SQL Server using SQL_Tools

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to insert binary data into SQL Server using SQL_Tools

    Anyone got a good method of inserting binary data into SQL Server?

    At first thought it is just a string but I would need to escape any single quote marks.

    Is there a more nice way where the binary data goes in untouched?

    I assume I can use VARCHAR(MAX) for small stuff and then what data type is the preferred these days for a .jpg or .mp3 etc...

  • #2
    Don't use any type of character field, use a binary field. (VARBINARY)

    SQL Tools Pro - SQL_UpdateBLOB lets you update a binary field with either a binary string or a file

    If you want to insert it in a new record, do the INSERT of core record data, retrieve the PK and then do an UPDATE for the binary data.



    Comment


    • #3
      SQL_Tools Pro has a SQL_UpdateBLOB function specifically for updating long binary columns in an SQL table. I've used it only once or twice, and am away from my desk and primary development machine (ad therefore, can't get to the help file). If I recall correctly, it's pretty easy -- unlike most SQL-Tools function where you construct something like this:

      Code:
      update mytable set BlobField = 'BlobData' where recnumber = 1
      and pass it to SQL_Tools to execute, the SQL_Blob function can only update the Blob column, which is specified in the function:

      Code:
      SQL_updateBlob(MyDatabase&, TableName$, Columnname$, whereclause$, BlobData$)
      Something like that. Again, it's off the top of my memory, I don't have the help file right at hand.

      Hope this helps
      Real programmers use a magnetized needle and a steady hand

      Comment

      Working...
      X