...Technology Simplified

Monday, April 23, 2012

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

No comments :
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. Here is the t-sql script that is causing the error message :
CREATE TABLE myTable(Document varbinary(max))
INSERT INTO myTable(Document)
SELECT * FROM OPENROWSET(BULK N'D:\DispatchAdvice.png', SINGLE_BLOB)
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.
CREATE TABLE myTable(Document varbinary(max))
INSERT INTO myTable(Document)
SELECT * FROM OPENROWSET(BULK N'D:\DispatchAdvice.png', SINGLE_BLOB) rs

No comments :

Post a Comment