I am trying to select from a sql file (which is a query itselft) if I paste the query as text instead of openrowset it works, but i just cant figure out the syntax below, to keep the file independent and reusable
select * from openrowset(bulk 'F:\Movimenti.sql', formatfile='F:\Movimenti.sql' ) as Test due to error: Msg 9422, Level 16, State 48, Line 3 XML parsing: line 1, character 0, incorrect document syntax
UPDATE
I have found another way to achieve this
declare @SequelFile varchar(max) declare @sql varchar(max) select @SequelFile=BulkColumn from openrowset(bulk 'F:\Movimenti.sql',single_blob) x set @sql = ' select * from openquery([Navision], ''' + @SequelFile + ''' ) as Derivedtbl ' exec (@sql)