As an example in executing Powershell scripts inside SQL Server or T-SQL stored procedures, I am getting the current data and time using Get-Date CMD code.
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
EXEC sp_configure 'show advanced options', 1 GO -- To update the currently configured value for advanced options. RECONFIGURE GO -- To enable the feature. EXEC sp_configure 'xp_cmdshell', 1 GO -- To update the currently configured value for this feature. RECONFIGURE GO --create stored procedure CREATE PROCEDURE SP_EXEC_Powershell AS BEGIN EXEC master..xp_cmdshell 'powershell.exe Get-Date' END --Execute StoredProcedure EXEC SP_EXEC_Powershell |
