Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

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

user-image
Question added by Sharif Khan , Software Engineer
Date Posted: 2014/07/09
Sudheesh Kunnool
by 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
by 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

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.