I want to update database from a .sql
file which contain some commands like update and edit and delete.
I try hard to pass the .sql
file to the procedure to make it run.
This is my code which only shows me the file instead of running it:
DECLARE @filePath nvarchar(1000)
DECLARE @command nvarchar(1000)
DECLARE @query nvarchar(1000)
SET @filePath = 'd:\amz\update_price001.sql'
SET @command = '(SELECT * FROM OPENROWSET(BULK '''+@filePath+''', SINGLE_CLOB) AS Contents)'
SELECT @command
SET @query = @command
EXEC sp_executesql @query
This is the result of the select @command
:
(SELECT * FROM OPENROWSET(BULK 'd:\amz\update_price001.sql', SINGLE_CLOB) AS Contents)
but the result of the EXEC sp_executesql @query
is the filecontent - not the execution result.