Windows 10: How to: Execute DOS commands from T-SQL

Discus and support How to: Execute DOS commands from T-SQL in Windows 10 Tutorials to solve the problem; Sometimes you might have the need to execute a copy, delete or run a batch file from a stored procedure. This can be done by using the xp_cmdshell and... Discussion in 'Windows 10 Tutorials' started by Noel, Jun 21, 2018.

  1. Noel New Member

    How to: Execute DOS commands from T-SQL


    Sometimes you might have the need to execute a copy, delete or run a batch file from a stored procedure. This can be done by using the xp_cmdshell and execute your command line.

    This can be done as below

    EXECUTE master..xp_cmdshell 'copy c:\test.txt c:\test1.txt'

    You can run it using parameters as below

    DECLARE @sql VARCHAR(200)
    SET @sql = 'copy c:\test.txt c:\test1.txt'
    EXECUTE master..xp_cmdshell @sql

    If you are running the xp_cmdshell and get the error "SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server." Follow the code below to enable the feature.

    EXEC sp_configure 'show advanced options', 1;
    GO
    RECONFIGURE;
    GO
    EXEC sp_configure 'xp_cmdshell', 1;
    GO
    RECONFIGURE;
    GO

    (32)

    read more...
     
  2. Brink Win User

    SQL Server Guidance against speculative execution vulnerabilities


    Source: https://support.microsoft.com/en-us/...for-sql-server
     
    Brink, Jun 21, 2018
    #2
  3. Execute a command from SCCM Task sequence step "Run a Command line"

    Hi,

    Thanks for your suggestion.

    That will work indeed, however I need to run it from the SCCM Task Sequence's Run Command Line Step and I am not able to figure out how to do that.

    Can we change line while executing command from SCCM Task Sequence's Run Command Line Step?

    Regards
     
    sccm_learner, Jun 21, 2018
    #3
  4. How to: Execute DOS commands from T-SQL

    SQL Error

    Am trying to reinstall SQL express and am getting below Error message.

    Error 27506, Error executing SQL script CreateDB. Line 27. CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (1802)
     
    AmosMacharia Kamau, Jun 21, 2018
    #4
Thema:

How to: Execute DOS commands from T-SQL

Loading...
  1. How to: Execute DOS commands from T-SQL - Similar Threads - Execute DOS commands

  2. DOS Command issued from Batch file

    in Windows 10 Network and Sharing
    DOS Command issued from Batch file: I have been running a batch file to list my personal file, and output the listing to a text file in a folder dv7. I then use the text file to compare to files on another computer or external drive, as backup. For some reason it no longer works. The command in the BAT file...
  3. how to remove dos mode from windos 10

    in Windows 10 Customization
    how to remove dos mode from windos 10: hey how i can remove dos mode from windos 10 https://answers.microsoft.com/en-us/windows/forum/all/how-to-remove-dos-mode-from-windos-10/628608cd-0fb4-4d58-a52e-cb7fece1a5b6
  4. How do I view Startup autoruns and execution commands?

    in Windows 10 Support
    How do I view Startup autoruns and execution commands?: Thank you for taking a look at my thread. I see a Startup "Windows host process (Rundll32)" rated "High". I am considering disabling it... How would I view the autoruns and look at the full execution commands? Much Obliged *cake 142148
  5. Intruder Alert!!? Executing remote command...

    in AntiVirus, Firewalls and System Security
    Intruder Alert!!? Executing remote command...: IS this what i think it is?[ATTACH] https://answers.microsoft.com/en-us/windows/forum/all/intruder-alert-executing-remote-command/c276edb8-fb9b-4f2c-8651-45719c699fa7"
  6. Execute Powershell command on remote computer

    in Windows 10 Network and Sharing
    Execute Powershell command on remote computer: Hello, I would like to execute a PowerShell command on a remote computer. The command is the following: Invoke-Command -ComputerName 10.40.27.174 -ScriptBlock { Get-ChildItem C:\ } -credential User I get the following error: [10.40.27.174] La connexion au serveur...
  7. How do i run cmd with commands already executed!

    in Windows 10 Support
    How do i run cmd with commands already executed!: OK say I wanted to run a cmd (I know I will have to use notepad so im pretty much asking the command and ending of the command ex. CMD.bat) For those that want to go ahead and be really helpful im looking to open cmd and do "color 4" Simple 99681
  8. SQL Server Guidance against speculative execution vulnerabilities

    in Windows 10 News
    SQL Server Guidance against speculative execution vulnerabilities: SQL Server Guidance to protect against speculative execution side-channel vulnerabilities Summary Microsoft is aware of a new publicly disclosed class of vulnerabilities referred to as “speculative execution side-channel attacks” that affect many modern processors and...
  9. Differences in format of DOS command results

    in Windows 10 Support
    Differences in format of DOS command results: OK, so I am doing some stuff in DOS, not geeky stuff but playing around. I have two computers that I can use, both with W10. So, I do a 'DIR' command, saving to a file, and then look at it. Then same again on the other computer. It annoys me that the format of the results...
  10. How To Create A Shortcut That Executes The "Undo" Command

    in Windows 10 Support
    How To Create A Shortcut That Executes The "Undo" Command: Hi, just a quick request. Does anyone know how to create a shortcut that I can open that will run the "Undo" command? For example: Suppose you have File Explorer open and delete a file from a folder. You can right click in that folder and click on "Undo Delete" to have...

Users found this page by searching for:

  1. how to run a java command from a sql server function?

    ,
  2. execute dos command in sql

    ,
  3. tsql exec dos command from proc

    ,
  4. set sql execute command,
  5. execute cmd from sql,
  6. how to run t-sql command,
  7. how to run windows command from SQL,
  8. how to run cmd commands in T-SQL,
  9. tsql how to run dos command,
  10. run dos command from tsql,
  11. sql dos commands,
  12. execute cmd command on sql,
  13. dos sql,
  14. using sql server agent to do dos file commands,
  15. how to run cmd command by t-sql