SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for ASP.Net, SQL Server, Reporting Services, T-SQL, Windows, AWS, SAP HANA and ABAP


A correlation name must be specified for the bulk rowset in the from clause.

While inserting image files into a SQL Server database table using the OPENROWSET function, I got the following error message from the SQL engine.

Msg 491, Level 16, State 1, Line 5
A correlation name must be specified for the bulk rowset in the from clause.

I soon realized that the error message is asking for a alias name for the OPENROWSET select statement.





Here is the t-sql script that is causing the error message :

INSERT INTO Files(fname, [file])
SELECT 'T-SQL-Enhancements-in-SQL-Server-2008', * FROM OPENROWSET(
  BULK N'C:\T-SQL-Enhancements-in-SQL-Server-2008.jpg', SINGLE_BLOB
)
Code

And the below sql script displays how the correct statement should be built.
Take your attention on the "rs" alias name at the end of the script.

INSERT INTO Files(fname, [file])
SELECT 'T-SQL-Enhancements-in-SQL-Server-2008', * FROM OPENROWSET(
  BULK N'C:\T-SQL-Enhancements-in-SQL-Server-2008.jpg', SINGLE_BLOB
) rs
Code


SQL Server

SQL Server 2019 Installation
download SQL Server 2019
download SQL Server 2017
download SQL Server 2016
download SQL Server 2014
download SQL Server 2012
MacOS ve SQL Server 2019


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.