473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Triggers and stored procedures in C#

FP
Hi,
i have read that with Visual Studio 2005 it's possible to create stored
procedures and triggers for a Sql Server 2005 database.
I must admit that i have already written the stored procedures and triggers
for my database using T-SQL,but i noticed bad performance (its kinda
slow),so i ask:writing them in C# would i achieve a (considerable)
performance gain?
Thanks in advance :)
Nov 21 '07 #1
5 1794
FP,

It really depends on what you are doing in the database. If you are
performing a lot of computational code (as opposed to set operations), then
yes, you could see a performance increase. However, if you are performing
what are really set-based operations, then using .NET in SQL Server isn't
going to help. Rather, you need to look at optimizing your queries and the
underlying database (indexes on tables the queries access) to improve
performance.

Can you give an example of something that is performing slow (a stored
procedure or trigger)? The actual code would be helpful.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"FP" <FP@nospam.comwrote in message
news:ci****************************@40tude.net...
Hi,
i have read that with Visual Studio 2005 it's possible to create stored
procedures and triggers for a Sql Server 2005 database.
I must admit that i have already written the stored procedures and
triggers
for my database using T-SQL,but i noticed bad performance (its kinda
slow),so i ask:writing them in C# would i achieve a (considerable)
performance gain?
Thanks in advance :)

Nov 21 '07 #2
Nicholas Paldino [.NET/C# MVP] ha scritto:
It really depends on what you are doing in the database. If you are
performing a lot of computational code (as opposed to set operations), then
yes, you could see a performance increase. However, if you are performing
what are really set-based operations, then using .NET in SQL Server isn't
going to help. Rather, you need to look at optimizing your queries and the
underlying database (indexes on tables the queries access) to improve
performance.
First of all thanks for your quick reply Nicholas :)
Unfortunately now i am at another computer,so i cant copy some code.
I am really a newbie to database programming,so please forgive this silly
question:what do you exactly mean with computational code?Complex
arithmetical computations?
In my T-SQL code,the only computational operations i do are using the AVG
command somewhere,but it is mostly based on select,update,insert
queries,tables creation and several types conversions (i have to deal a lot
with datetime type).I also have some while loops.
So i think my T-SQL code might be enough.Do you confirm this?
Thanks again for your help :)
Nov 21 '07 #3
FP (Olmo),

When I say computational, I mean things like processing strings
(splitting a string apart, for example) rather than seeing if a value exists
in a column in a table (set operation).

Based on what you said, it seems like you need to create better queries
and possibly index in some places. It doesn't sound like you are doing
anything computationally intensive (at least in terms of what T-SQL is
doing), just set-based operations.

Also, if you have while loops, you might be able to condense that into a
single operation, depending on what you do in the while loop.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Olmo" <ir****@nospam.comwrote in message
news:gf****************************@40tude.net...
Nicholas Paldino [.NET/C# MVP] ha scritto:
>It really depends on what you are doing in the database. If you are
performing a lot of computational code (as opposed to set operations),
then
yes, you could see a performance increase. However, if you are
performing
what are really set-based operations, then using .NET in SQL Server isn't
going to help. Rather, you need to look at optimizing your queries and
the
underlying database (indexes on tables the queries access) to improve
performance.

First of all thanks for your quick reply Nicholas :)
Unfortunately now i am at another computer,so i cant copy some code.
I am really a newbie to database programming,so please forgive this silly
question:what do you exactly mean with computational code?Complex
arithmetical computations?
In my T-SQL code,the only computational operations i do are using the AVG
command somewhere,but it is mostly based on select,update,insert
queries,tables creation and several types conversions (i have to deal a
lot
with datetime type).I also have some while loops.
So i think my T-SQL code might be enough.Do you confirm this?
Thanks again for your help :)

Nov 21 '07 #4
I hope I'm not barging in on the general theme here as I've already read
Nick's replies. But my approach has been that I only will look at using
CLR-hosted stored procs that call into .NET managed code when there is no
compatible functionality in T-SQL. For example, if you need to be able to get
an RSS Feed and store it in a database table, there is no native T-SQL code
that will do this, so you would write a GetRSSFeed (url) CLR-hosted assembly
/ class with a T-SQL front end that would do this and install it in Sql
Server 2005 +.
---Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"FP" wrote:
Hi,
i have read that with Visual Studio 2005 it's possible to create stored
procedures and triggers for a Sql Server 2005 database.
I must admit that i have already written the stored procedures and triggers
for my database using T-SQL,but i noticed bad performance (its kinda
slow),so i ask:writing them in C# would i achieve a (considerable)
performance gain?
Thanks in advance :)
Nov 21 '07 #5
Further to the other replies... remember that your database is the
hardest thing to scale out, and scaling up gets really expensive
really quickly...

Unless there is a significant reason to use .NET in the database (i.e.
you absolutely need something that T-SQL doesn't provide, such as zip/
crypto-stream support), then stick with T-SQL and let your database
worry about set-based data operations. There are /lots/ of ways to
write better T-SQL to improve performance, but it takes time to learn
the tricks and when each trick can help.

Marc
Nov 22 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: serge | last post by:
How can i delete all user stored procedures and all table triggers very fast in a single database? Thank you
1
by: Manish Bafna | last post by:
speaking of me, I'm not very new to Access, but I haven't worked on it as a professional. I know that you can fire queries in Access, but I don't think you can create views. i want to know that...
1
by: jagdpenta | last post by:
This is my second post What are the advantages of stored procedures, triggers, indexes E-Mail address blocked: See forum rules - moderator Thanks in advance
1
by: Miaaa Mukherjee | last post by:
Hello, I want to know something about the stored procedures and triggers which are used. I want to know that the procedures n triggers r created in SQL Server 2005 or...
2
by: cvraghavan1979 | last post by:
Hi guys, let me know the difference between the use of direct queries and the stored procedures / Triggers. also pls specify the advantages of using the stored procedures / triggers....
2
by: sonia.sardana | last post by:
Hey can anyone tell me whether Triggers and Stored Procedures are same? Triggers are stored procedures that get executed automatically when an Insert,Update,or Delete operation takes place. ...
4
by: --CELKO-- | last post by:
I need to convert a bunch of DB2 triggers to Oracle. Is there any kind of tools for this?
1
by: anuragshrivastava64 | last post by:
I am new to SQL Server. I have got a project where lot of stored procedures ,UDF's and triggers are used. The problem is I am finding all the functions and procedures but not been able to find any...
2
by: ajaysbedi | last post by:
Hi, I have 2 triggers on a table, both triggers are updating the another table create trigger DB.TRG1 AFTER INSERT ON Table1REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL WHEN ( NEW.DEPT <>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.