ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل Sharif Khan , Senior Software Engineer , Bhanva Corp
تاريخ النشر: 2014/07/09
Sudheesh Kunnool
من قبل 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
من قبل 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.

المزيد من الأسئلة المماثلة