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
 Site Related Forums
 Article Discussion
 Article: Writing CLR Stored Procedures in C# - Returning Data (Part 2)

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-06-23 : 16:12:59
In Part 1 I covered a simple stored procedure that printed the current date. In this article I'll cover writing a stored procedure to return a recordset back to the client. In the process we'll learn a little bit more about .NET and C# including the SqlConnection, SqlCommand and SqlDataReader classes.

Article Link.

karuna
Aged Yak Warrior

582 Posts

Posted - 2005-06-26 : 02:59:54
Hmm...Interesting...Actually I havent looked at both VS.NET 2005 and Sql Server 2005 yet...But what I see from the code is why should I have to do all this to create a stored proc in Sql Server or is it that, this is way it should go and no more T-Sql in Sql Server 2005?

Karunakaran
___________
It's better to be loved and lost, than ever to be loved...
Go to Top of Page

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2005-06-26 : 12:01:41
Transact-SQL still exists in SQL Serve 2005. For the types of examples I've shown so far it would probably be best to use T-SQL in those areas. I'm trying to use these types of examples to demonstrate how to code in C#. As a general rule of thumb T-SQL will be better for data access and CLR (C#/VB) will be better to processor intensive tasks (string manipulation, math, etc.). In future articles the examples will get more complex.

===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page

karuna
Aged Yak Warrior

582 Posts

Posted - 2005-06-27 : 01:09:57
When I looked at the code first, I thought this is the code we write in an .net application to execute a sql query or to call a stored proc, So why should I do this to write a stored proc.
Now I get your point of demonstrating how to code in C#. Pretty good one. What I didnt understand in that code is, why using pipe there? Any pointers or explanations on that?

Looking forward for complex examples !!!

Karunakaran
___________
It's better to be loved and lost, than ever to be loved...
Go to Top of Page

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2005-06-27 : 21:34:04
Did you read the first article (http://www.sqlteam.com/item.asp?ItemID=21927)? The pipe is the way of sending results outside the stored procedure (i.e. back to the whatever called the stored procedure).

===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page

karuna
Aged Yak Warrior

582 Posts

Posted - 2005-06-27 : 23:54:38
I did read the first article.Will check more on pipe.
Thx for the explanation Graz.

Karunakaran
___________
It's better to be loved and lost, than ever to be loved...
Go to Top of Page

mksql
Starting Member

1 Post

Posted - 2005-08-30 : 12:02:53
Looking forward to Part 3. Any ETA?
Go to Top of Page

jwaz1999
Starting Member

12 Posts

Posted - 2007-06-29 : 16:38:09
The only problem with this post is there is no SPROC created. It's just executing dynamic SQL. Stored procedures provide many advantages over dynamic SQL including security, caching, and speed.

Jeff W.
Go to Top of Page

cdjn
Starting Member

1 Post

Posted - 2007-07-09 : 23:16:31
Hi guys,
I want to create a sp with diferents schemas. VS2005 always create it in dbo schema. Do you know how to create that with diferent schema??

thanks guys,

cdjn.
Go to Top of Page
   

- Advertisement -