You are on page 1of 3

Assignment – Lab 2

Roll No : 2012064


1. sp_addlogin: Creates a new Microsoft SQL Server login that allows a
user to connect to an instance of SQL server using SQL server
2. sp_grantlogin: Allows a user or group account to connect to
Microsoft SQL Server using Windows authentication.
3. sp_revokelogin: Removes the login entries from Microsoft SQL Server
for a user or group created with sp_grantlogin or sp_denylogin.
4. sp_password: Adds or changes a password for a Microsoft SQL
Server login.
5. sp_defaultdb: Changes the default database for a login.
6. sp_denylogin: Prevents a user or group from connecting to Microsoft
SQL Server.
7. sp_dropserver: Removes a server from the list of known remote and
linked servers on the local Microsoft SQL Server.
8. sp_droplogin: Removes a Microsoft SQL Server login, preventing
access to SQL Server using that login name.
9. sp_databases: Lists databases that reside in an instance of Microsoft
SQL Server or are accessible through a database gateway.
sp_fkeys: Returns logical foreign key information for the
current environment showing foreign key relationships including
disabled foreign keys.
sp_pkeys: Returns primary key information for a single table
in the current environment.
sp_linkedservers: Returns the list of linked servers defined in
the local server.
sp_primarykeys: Returns the primary key columns, one row
per key column, for the specified remote table.
sp_tables_ex: Returns table information about the tables from
the specified linked server.
sp_attach_db: Attaches a database to a server.
sp_help: Reports information about a database object, a userdefined data type, or a data type supplied by Microsoft SQL Server.
sp_who: Provides information about current Microsoft SQL
Server users and processes.
sp_stored_procedures: Returns a list of stored procedures in
the current environment.
sp_foreignkeys: Returns the foreign keys that reference
primary keys on the table in the linked server.

4. Inline Function can be thought of as views that take parameters and can be used in JOINs and other Rowset operations. Functions can have only input parameters for it whereas Procedures can have input/output parameters. Advance Difference 1. 5. This can be used in JOINs with other tables. 7. 3.20. 2. Procedures cannot be utilized in a SELECT statement whereas Function can be embedded in a SELECT statement. Exception can be handled by try-catch block in a Procedure whereas try-catch block cannot be used in a Function. 2. Functions that return tables can be treated as another rowset. Stored Procedures cannot be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section whereas Function can be. Basic Difference 1. Functions can be called from Procedure whereas Procedures cannot be called from Function. sp_indexes: Returns index information for the specified remote table. 2) Differences between stored procedure and a function: Stored Procedures are pre-compile objects which are compiled for first time and its compiled format is saved which executes (compiled code) whenever it is called. For more about stored procedure and function refer the articles Different types of Stored Procedure and Different types of Function. Procedure allows SELECT as well as DML(INSERT/UPDATE/DELETE) statement in it whereas Function allows only SELECT statement in it. . But Function is compiled and executed every time when it is called. 6. The most important feature of stored procedures over function is to retention and reuse the execution plan while in case of function it will be compiled every time. Function must return a value but in Stored Procedure it is optional (Procedure can return zero or n values). 3.

We can go for Transaction Management in Procedure whereas we can't go in Function.8. .