

In my little example here I am assuming that I have a list of employee names who have each provided a “selfie” image file saved in the jpg file format: The table will have a “typical” Employee ID (defined as an IDENTITY) and Name (NVARCHAR) but will also include two additional columns which will hold the name of the physical image file stored as the NVARCHAR data type and also the binary data of that image file stored as the VARBINARY data type (previously, you might have used the IMAGE data type).īelow is the simple T-SQL script I used to create the table: Now that I have the prerequisite work completed, I can go ahead and create a table that will hold the images. Here is the T-SQL script that grants those privileges (I am assigning the bulkadmin role to myself): These are extended stored procedures that allow SQL Server users to execute functions external to SQL Server within the security context of SQL Server. The SQL Server Ole Automation Procedures option controls whether OLE Automation objects can be instantiated within Transact-SQL batches. That is, the OLE Automation Procedures option must be “set and active” on the SQL Server instance to be used for the image export action I’ll use and the bulkadmin server role (which grants bulk copy and other bulk operations) must be given to the user who will be importing and exporting images. There is a preliminary step I must do to make this example work. Not sure which tool to use? Review a comparison between the tools here.įor this exercise, I am assuming that you have some basic understanding of the use of Azure Data Studio (logging in and connecting to a database, executing queries, etc.) but if not, there is a helpful QuickStart guide. I would like to import images for each employee from a source location into a table and then be able to export the image for processing later.įor this exercise I chose to use Azure Data Studio and an on-premises SQL Server database, but you could just as easy use SQL Server Management Studio (SSMS). Here, lets imagine an employee database where, included with identification information, is a unique image of the individual. Recently, Microsoft began suggesting using VARBINARY(MAX) instead of IMAGE for storing a large amount of data in a single column since IMAGE will be retired in a future version of MS SQL Server.Īs always, I think the best way to understand something is via a working example. The IMAGE data type in SQL Server has been used to store the image files.
