December 20, 2017 at 6:42 am
Hi,
I want to execute a .sql script within a stored procedure but I want to do it without enabling xp_cmdshell.
Any ideas?
January 4, 2018 at 3:40 am
I didn't try this way but it could work. You could use a BULK INSERT and write the content of the .sql file into a table and then execute this content as dynamic SQL.
January 4, 2018 at 3:49 am
juniorDBA13 - Wednesday, December 20, 2017 6:42 AMHi,I want to execute a .sql script within a stored procedure but I want to do it without enabling xp_cmdshell.
Any ideas?
Are you sure that's a good idea? You'd want to make very sure that nobody has access to modify the .sql file, otherwise all sorts of damage could be done.
John
January 4, 2018 at 3:54 am
What is the .sql file doing? Why are you wanting to execute SQL from a file in a (shared) file path? Is it so that it can be dynamic? Is it procedurally generated perhaps? There are far safer ways than just executing a .sql file. Like John said, if anyone has access to modify it, they could easily do a huge amount of damage.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
January 4, 2018 at 8:31 am
Thom A - Thursday, January 4, 2018 3:54 AMWhat is the .sql file doing? Why are you wanting to execute SQL from a file in a (shared) file path? Is it so that it can be dynamic? Is it procedurally generated perhaps? There are far safer ways than just executing a .sql file. Like John said, if anyone has access to modify it, they could easily do a huge amount of damage.
+ 1,000,000 to that!
--Jeff Moden
Change is inevitable... Change for the better is not.
January 4, 2018 at 8:34 am
juniorDBA13 - Wednesday, December 20, 2017 6:42 AMHi,I want to execute a .sql script within a stored procedure but I want to do it without enabling xp_cmdshell.
Any ideas?
This is a form of "Death by SQL" no matter how you do it. Perhaps if you explained why there's a need to do such a thing and what the script(s) will actually do, we might be able to recommend a much safer method.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply