what is Stored Procedures, triggers, functions in asp.net, sqlserver.

Posted by Dn2010 under Interview Questions on 2/14/2011 | Points: 10 | Views : 4607 | Status : [Member] | Replies : 7
hi friends,

what is Stored Procedures, triggers, functions in asp.net, sqlserver.

how to use it ,

please give in detail.

thanks.




Responses

Posted by: Karthikanbarasan on: 2/14/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

In simple words

Stored procedures are set of tSQL queries predefined and kept as a package to be executed at the same time by different clients.

Functions also provides the same functionality but it has some advantages like, we can call function in a SELECT Statement which we cant do with Stored Procedure.

Triggers are typically used in order to audit a table like, if any inserts, update, delete occurs on the table then we can audit the DML in another table

Thanks
Karthik
www.f5Debug.net

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 2/15/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
And you can execute or use all of them in ASP.Net using ADO.NET.

Thanks and Regards
Madhu

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 2/15/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi dn2010

i am refer u this link it's a use full for you . .

http://www.beansoftware.com/ASP.NET-Tutorials/ASP.NET-SQL-Server.aspx

Best Regard's
Prabhakar

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 8/2/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi dn2010,

Store Procedure, Triggers and functions are database objects.
as they are database objects, they created, used and maintained in sql server.
among them Procedure and Functions are called from business objects, where as triggers is like events, they called automaticaly
all three object consist of tSql statements which are meant to perform some task.

it's good programming practice to create procedure and functions for database activities

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naga116 on: 8/6/2011 [Member] Starter | Points: 25

Up
0
Down
Stored Procedure: This is nothing but an executing your business logic.
It can perform multiple DML (insert,update,delete) operation in single execution.
One Stored procedure can be called another stored procedure.
Basically it may or may not return data using Cursors.
We can keep Commit and Rollback

Function : A Function is used work for a small calculations.
It is expecting an input and producing must single out put value( like aggregate functions take multiple values for average of salaries and provide one value).
A function can be call in a Select command but stored procedure can not call.
Cannot accept Transaction statements like(Commit and RollBack)

Trigger : It is event fire based on the DML operation performed on a table.
Ex: If Table having any updation using insert operation immediate TableB having delete operation will occur.




Nagaraju

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/13/2012 [Member] Bronze | Points: 25

Up
0
Down
Stored Procedure:-
1)Procedures can have input/output parameters for it
2)A set of pre compiled SQL statement. Execution of SP will be fast because it is already compiled. Main advantage is it is re-usable and execute faster.
3)Exception can be handled by try-catch block in a procedure.
4)procedures cannot be called from function.

Functions:-

1)This is also a set of SQL statements but it always returns values. Functions will be executed only when it is called. You can call function from a stored procedure.
2) functions can have only input parameters.
3)Functions can be called from procedure

Trigger:-

1)Triggers gets executed automatically, you don't need to call explicitly in fact you cannot call triggers explicitly it is mostly tied up with a table.
2)we can't pass the parameters as an input to a trigger.
3)trigger cannot return a value.
4)we can't call a trigger from front end files

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/14/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi DN2010,
Please Mark as Answer if it helpful to you..That helps other who search the same...

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response