Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 stored procedure syntax tutorial

Author  Topic 

olibara
Yak Posting Veteran

94 Posts

Posted - 2011-03-03 : 01:38:54
Hello
I've a good experience in general programming C#, C++, VB,, etc
But I'm totaly newbee for stored procedure
I can already create a simple select SP with parameter
But I don't know anything else about the subtility of SP language
Where can I found a little tutorial about SP syntax

BTW : what is the difference between SP and Functions ?

Thanks for your help

Ranjit.ileni
Posting Yak Master

183 Posts

Posted - 2011-03-03 : 01:54:06
Hi,
you can find an useful article on SQL Server Stored Procedure
http://www.mssqltips.com/tutorial.asp?id=160


and Here is the some Difference between Stored Procedure and User Defined Functions:

Procedure can return zero or n values whereas function can return one value which is mandatory.

Procedures can have input,output parameters for it whereas functions can have only input parameters.

Procedure allow select as well as DML statement in it whereas function allow only select statement in it.

Functions can be called from procedure whereas procedures cannot be called from function.

Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.

We can go for transaction management in procedure whereas we can't go in function.

Procedures can not be utilized in a select statement whereas function can be embedded in a select statement.

We can call the functions in SQL statements (select max(sal) from emp). We cannot call Stored Procedures in SQL Statements.


--Ranjit
Go to Top of Page

olibara
Yak Posting Veteran

94 Posts

Posted - 2011-03-03 : 02:47:04
Thank you Ranjit.ileni

It help but i didnt found in this little tutorial any syntax example for conditionnal statement, loop, etc..

Is there some ?

Thanks
Go to Top of Page
   

- Advertisement -