Can a Linux script be run from stored procedure in a SQL Server database?

gfttwv5a  于 2023-10-15  发布在  Linux
关注(0)|答案(2)|浏览(108)

I want to run a shell script from a stored procedure as a workaround to achieve functionality not offered by tool by default.

Is it possible? Database is SQL Server, bash shell

fafcakar

fafcakar1#

Nope the approved answer is totally wrong. At the moment even with SQL Server 2022 xp_cmdshell isn't usable with the linux version.

https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-editions-and-components-2022?view=sql-server-ver15#unsupported-features-and-services

dzjeubhm

dzjeubhm2#

Yes. Check out https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql?view=sql-server-ver15 . To use xp_cmdshell you have to activate it, this is done with the commands:

-- this turns on advanced options and is needed to configure xp_cmdshell
sp_configure 'show advanced options', '1'
RECONFIGURE
-- this enables xp_cmdshell
sp_configure 'xp_cmdshell', '1' 
RECONFIGURE

相关问题