CREST Practitioner Security Analyst (CPSA) Practice

Disable ads (and more) with a membership for a one time $2.99 payment

Master the CREST Practitioner Security Analyst Exam. Prepare with quizzes and comprehensive study guides that include tips and explanations. Excel in your certification journey!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What command can be used to execute an operating system command in MS-SQL?

  1. SELECT version()

  2. EXEC master..xp_cmdshell 'net user'

  3. SHOW TABLES

  4. SELECT * FROM v$instance

The correct answer is: EXEC master..xp_cmdshell 'net user'

The choice of using EXEC master..xp_cmdshell 'net user' is the correct option for executing an operating system command in Microsoft SQL Server. The xp_cmdshell stored procedure allows you to run command-line commands directly from SQL Server. By enabling this feature, you can issue commands as if you were at the command prompt, which is especially useful for administrative tasks and scripts that need to interact with the operating system. The other options provided do not relate to executing operating system commands. SELECT version() is typically used in MySQL to retrieve the version of the database server, not in MS-SQL. SHOW TABLES is also a command used in MySQL to list all tables in a database, which again means it’s not applicable here. Lastly, SELECT * FROM v$instance is specific to Oracle databases, providing information about the running instance but does not execute OS commands. By understanding these distinctions, it's clear why the choice involving xp_cmdshell is uniquely suited for this task in MS-SQL.