Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between stored procedures and extended stored procedures

What is the basic difference between SQL Server stored procedures (sp_) and extended stored procedures (xp_)? Why there are extended procedures anyway?

like image 488
juur Avatar asked Jun 16 '10 18:06

juur


People also ask

What are extended stored procedures?

Extended stored procedures are DLL files which are referenced by the SQL Server by having the extended stored procedure created which then reference functions or procedures within the DLL. The DLLs which are behind the extended stored procedures are typically created in a lower level language like C or C++.

What are the two types of stored procedures?

Types of Stored ProceduresUser-defined Stored Procedures. System Stored Procedures.

What is the difference between stored procedure and procedure?

Answers. 1) Procedure is a block of PL/SQL code , it never stored in database. and 3) Stored procedure is block of PL/SQL code it is named and stored within the database.

What is the difference between stored procedure and stored function?

In a function, it is mandatory to use the RETURNS and RETURN arguments, whereas in a stored procedure is not necessary. In few words, a stored procedure is more flexible to write any code that you want, while functions have a rigid structure and functionality.


2 Answers

Extended stored procedures are written in c/c++(I believe anything that can create a DLL in native code), stored procedures are written in T-SQL

extended stored procedures exist because they allow you to do things that you cannot do in T-SQL like running DOS command (xp_cmdshell)

BTW do not name your procs starting with sp_..that is bad practice...see Don't start your procedures with SP_

like image 128
SQLMenace Avatar answered Nov 11 '22 23:11

SQLMenace


An extended stored procedure executes code that is not SQL. It's normally written with external code like in C++.

Using Extended Stored Procedures

like image 32
kemiller2002 Avatar answered Nov 12 '22 00:11

kemiller2002