Hello, I have been trying for extended time to create a bulk insert that can use a FROM 'filename' based on a table field, when I do not have access to sp_executequery but i do have EXEC. I have got close as collecting the filename from a table in dynamic sql. Now i need help with Inserting the filename returned by @query (example: C:\temp\filename') into a bluk insert. Here is the code i have:
Powershell
DECLARE@queryNVARCHAR(MAX)SET@query=@query+'DECLARE @query NVARCHAR(MAX); SELECT FILENAME FROM dbo.vw_lmsfilenames WHERE RowID = 2'EXECUTE(@query)print@queryBULKINSERT[tempdb].[dbo].[LMSCourseCatalogEvents]FROM@query
Remember that @query does successfully print out C:\temp\filename