Saturday, January 24, 2015

Learn Querying SQL Server 2012 using LinqPad - Part 3 Stored Procedures

You can execute stored procedures with LinqPad. In order to do so you need to know the details of the stored procedure which can reviewed in SQL Server Management Studio as shown here for a stored procedure in AdventureWorks2012. Review Learn Querying SQL Server 2012 using LinqPad parts 1 and 2.

Create a simple test stored procedure as shown:

Create Procedure dbo_PP
@fname as nvarchar(10),
@lname as nvarchar(20)

as
Select * from Person.person
Where
FirstName=@fname and LastName=@lname

go


This stored procedure requires two arguments, @fname and @lname for its evaluation.

Let us examine and execute this procedure first in SSMS and then in LinqPad.
In SSMS:
You find this stored procedure in the Programmability folder as shown.
This can be executed in SSMS as shown. Two paramters are provided


Once this procedure is created you can access it in LinqPad (review posts Part1 and Part2 )


It can be executed two ways in LinqPad; as a C# expression or SQL 

Evaluated as SQL:


Now evaluted as C# Expression:


Now as SQL:


This is how you get the return value:








No comments:

Post a Comment

Do you know what you installed while custom installing SQL Server 2022?

 When you install any software in Windows OS, the key information gets into the Registry and some of which you can look up in the control pa...