You do not have permission to use the bulk load statement error

前端 未结 3 832
灰色年华
灰色年华 2021-02-18 22:20

I am trying to insert an image into a VARBINARY(MAX) column. I get this error:

You do not have permission to use the bulk load statement.

相关标签:
3条回答
  • 2021-02-18 22:37

    Possibly one needs

    ALTER ROLE [sysadmin] ADD MEMBER [user]
    

    For example - in the current Linux version of SQL Server bulkadmin role is not supported and one needs to use a sysadmin to BULK INSERT. It is a known issue with SQL Server https://github.com/MicrosoftDocs/sql-docs/issues/4198 - SQL Server on Linux has permissions and roles that are not granular enough.

    0 讨论(0)
  • 2021-02-18 22:48

    To make sure you have the right permissions to use BULK commands follow the below

    • Expand Security
    • Expand Logins
    • Right click on your username and choose properties (A dialog window appears)
    • Choose Server Roles
    • Select bulkadmin to be able to use bulk commands or sysadmin to be able to use any commands to your database.

    Now, in regards to the query your are using it's not quite right.

    For creating the table

    CREATE TABLE [dbo].[Stickers] (
            [name] varchar(10)
            , [category] varchar(10)
            , [gender] varchar(1)
            , [imageData] varchar(max)
    )
    

    For inserting the large value data

    INSERT INTO  [dbo].[Stickers] ([name], [category], [gender], [imageData])
    SELECT 'Red dress'
            , 'Dress'
            , 'F'
            , photo.*
    FROM OPENROWSET(BULK 'C:\Users\username\Desktop\misc-flower-png-55d7744aca416.png', SINGLE_BLOB) [photo]
    

    A couple of notes:

    • You need to set a correlation name for the bulk rowset after the FROM clause ([photo])
    • Use the right column prefix that has been used for the correlation of the bulk rowset (photo.*)
    • The column for the bulk insert needs to be set as varchar(max)

    MSDN article for this: here

    0 讨论(0)
  • 2021-02-18 23:02
    ALTER SERVER ROLE [bulkadmin] ADD MEMBER [user]
    
    0 讨论(0)
提交回复
热议问题