Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

What is cursor,function and procedure in sql server 2008. Please explain briefly and wisely? thank you.

user-image
Question ajoutée par Sharif Khan , Senior Software Engineer , Bhanva Corp
Date de publication: 2014/07/09
Sudheesh Kunnool
par Sudheesh Kunnool , Senior Programmer & Database Administrator (Remote) , Timekiosk AS

A cursor in SQL server is a variable which  can hold records from a select statement (in other words a cursor is a recordset).  Use cursor when we need to loop through a select resultset. 

Stored procedures are reusable code blocks which is saved as a database object in the SQL Database. It can be compared to subroutines in any programming language(C#, VB.NET, etc). SPs can be used to validate the data, or perform complex and repeated tasks against the database. Use Stored procedures when you have to use same query over and over against the database.

 

Functions in SQL Server can be compared to functions in any programming language. Function can return values, and can be used as part of select statements in SQL Server queries. A function can return values from any simple type to complex CLR data types.

 

Abdul Moiz
par Abdul Moiz , Regional Treasury Officer , Siemens Middle East Limited

Cursor is a sophisticated way of performing loops in sql; when need to apply operations on whole table records.

More Questions Like This