Re: Inline SQL or stored procs for my C# windows app?
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 23 Apr 2007 13:34:31 -0400
Burt,
Well, it kind of is one of those "no right answer" questions. It always
depends on context.
If you have a routine that is going to be called over and over again,
then there really is no reason to not have it in a stored procedure.
Yes, you will have to migrate these if you move to another database, but
honestly, how hard is it to move a stored procedure from one database to
another? If you have dynamic sql, then you are going to run into the same
problem, you will have to change the dynamic sql generator (or strings for
the sql) to make sure you are not using any database-specific features.
Just because you are using dynamic sql doesn't mean that you are not
using database-specific features in the dynamic sql.
Honestly, I would use something like the Data Access Application Block
in the Enterprise Framework that is offered by Microsoft. It will help
mitigate using stored procedures and changing from one database to another
(you won't have to worry about changing how you call stored procedures from
managed code, for example), and you can use the object model exposed by it
to generate dynamic sql that will work across any database that has a
provider for the DAAB, assuming you don't use any database-specific features
in your SQL.
Personally, I think that dynamic sql has a place, but for established
logic which will be called repeatedly, stored procedures are the way to go.
For me, I would use dynamic sql for things like persisting an object model
to the database, but not performing multi-statement logic against the
database.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"Burt" <burt_5920@xxxxxxxxx> wrote in message
news:1177348117.001857.213900@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm a stored proc guy, but a lot of people at my company use inline
sql in their apps, sometimes putting the sql in a text file, sometimes
hardcoding it. They don't see much benefit from procs, and say anyway
they're are db specific- what if we change from SQL Server to Oracle
one day?
What say you experts? Is this one of those "no right answer"
questions?
Thanks,
Burt
.
- Follow-Ups:
- References:
- Prev by Date: RE: Object reference not set to an instance of an object
- Next by Date: Re: Object reference not set to an instance of an object
- Previous by thread: Inline SQL or stored procs for my C# windows app?
- Next by thread: Re: Inline SQL or stored procs for my C# windows app?
- Index(es):
Relevant Pages
|