I quite like storing SQL in text files embedded as resources into the assembly (when I absolutely have to have a significant number of them; I'm an ORM man normally).
Quite how you format that text file is up to you, of course. You could have double-line-break delimited:
UpdateCustomer:
UPDATE CUSTOMER SET NAME=@Name WHERE ID=@ID
FindCustomer:
SELECT NAME, ADDRESS FROM CUSTOMER
WHERE ID=@Id
etc
It's not hard to then have a class which loads that into a Dictionary<string,string>
in a type initialier, or even a Dictionary<string,SqlStatementHelper>
where the latter is a class to make it easy to prepare the statement with appropriate values. You could use any other format you want though, including XML - although if you didn't need anything else beyond the name/sql pairs, that would probably be overkill.
The downside of this is the disconnect between the SQL and the code that uses it - you can't instantly tell what the parameters are without looking at the text file. On the other hand (and I'm just thinking off the cuff here) you probably could autogenerate a class from the SQL (and a bit of metadata) with methods with strongly typed parameters.
The mixed blessing of stored procs is that they live in the database rather than in your code. The upside of this is that you're more likely to keep them in sync with DDL changes. The downside is that they're more effort to change (IME, anyway) than queries defined locally. (There are obviously plenty of other pros and cons, but I'm limiting myself to the convenience side here.)
As for maintenance - well, I suppose it's possible that you'd have a "database only" update of just tables and stored procs, without any clients having to know at all - in which case the stored procs would be a better move. In my experience (certainly with custom solutions where there are only a couple of applications accessing the database, so compatibility isn't as much of an issue) code changes are almost ubiquitous but database changes less so - at which point storing the queries with the application means you're less likely to have to do a database change when you update. Does any of that make sense? I haven't had coffee yet...