473,787 Members | 2,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1809
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.co m

"FP" <FP@nospam.comw rote in message
news:ci******** *************** *****@40tude.ne t...
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,i nsert
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.co m

"Olmo" <ir****@nospam. comwrote in message
news:gf******** *************** *****@40tude.ne t...
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,i nsert
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
2212
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
14359
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 is there any way to create stored procedures or triggers in Access. Also, I want to know that can we migrate data from any platform? i downloaded this rdbms s/w from http://www.vaman.net/vmndataserver.asp i tried this s/w. this solved my most of...
1
2956
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
1042
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 Visual Studio.Net 2005 ???? Though it may be silly question for all the experts so pls answer me. Can anyone suggest me any online book guide which shows the information abt this...
2
1272
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. regards, vijay
2
1402
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. Stored Procedures.------???? If i m right,Stored procedures are similar to Functions in C??
4
5746
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
4339
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 of the TRIGGERS. Can anyone plz tell me where can I find the triggers. I used the query (Select * from Sysobjects) and it shows 52 triggers
2
2247
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 <> OLD.DEPT)CALL COBOL_SP1 (NEW.DEPT,NEW.DEPT_NO) CREATE TRIGGER DB.TG2 AFTER INSERT ON Table1REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL WHEN ( NEW.DEPT =222 and OLD.DEPT = 111) CALL COBOL_SP2 (NEW.DEPT,NEW.DEPT_NO); Basically i need to merge...
0
9655
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10169
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.