Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does EXEC master.. Do?

I have seen this like:

EXEC master.dbo.xp_cmdshell

What does master refer to?

Update
And why sometimes is followed by two points:

 master..

generally we would use master.dbo. Am I correct, so why some people write master..?

like image 670
edgarmtze Avatar asked Mar 07 '11 05:03

edgarmtze


People also ask

What can Xp_cmdshell do?

The xp_cmdshell is a very powerful extended procedure used to run the command line (cmd). This is very useful to run tasks in the operative system like copying files, create folders, share folders, etc. using T-SQL.

What does EXEC do in SQL?

The EXEC command is used to execute a stored procedure.

What can be used instead of Xp_cmdshell?

As we have discussed before , xp_cmdshell is a mechanism to execute arbitrary calls into the system and because of the flexibility of its nature, it is typically abused and leads to serious security problems in the system.

What does EXEC mean in SQL Server?

The EXEC command is used to execute a stored procedure, or a SQL string passed to it. You can also use full command EXECUTE which is the same as EXEC.


2 Answers

master is one of the default SQL Server system databases. You can tell because what you posted:

EXEC master.dbo.xp_cmdshell

...uses the three name notation. "master" is in the database position, "dbo" is the schema, and "xp_cmdshell" is the function/stored procedure in this case. You use this notation for also referring to tables and views, in different contexts.

This:

EXEC master..xp_cmdshell

...just omits the schema, but isn't a good idea if there are more than one schema being used in a database.

like image 110
OMG Ponies Avatar answered Sep 21 '22 20:09

OMG Ponies


It refer to a stored procedure that has been created (by default) in the master table.

The name master refer to the database that contains the different schema of your server instance.

like image 24
Pierre-Alain Vigeant Avatar answered Sep 18 '22 20:09

Pierre-Alain Vigeant