SQL for Smarties | SQL Programming Style | Trees and Hierarchies in SQL | SQL Puzzles and Answers | Data and Databases

Sunday, June 25, 2006

Storing SQL in a table

SQL Apprentice Question
I have a project where I'm trying to "patch" something that probably
needs a rewrite. It currently has some code set in a dll that gets
called in order to give the app calling it the appropriate code to pull
info from a database.

Rewriting it is not an option at this point.

I had the idea of putting code into a SQL table, which would be
associated with a username, that I would then read & put into the sql
that is called within the dotnet application.

Currently, I have to make a change to the dll in order to make a change
at all to the app, which is something I would like to get around having
to do.

I already know what I need to put into the table in order to 'store" the
sql code in it, but I can't get it to take over a few hundred
characters, no matter what type of field I change it to.

Is there a way to store sql into a field in a table? If so, how? I
know the code is right, it has the ' ' where the single quotes need to
be, but it still gets truncated.

Is there a better way to do this, that (a) won't necessitate a program
change each time the data potentially changes? and (b) will make it able
to be called in a manner that would give me the entire piece of code needed?

Celko Answers

Blasting Cap wrote:
> I have a project where I'm trying to "patch" something that probably [needs] rewriting it is not an option at this point. <<

Based on a mere 30+ years in the trade, I think this phrase means "It
is time to update the resume and look for a new job; this company is
dead in a year."

Kludging things only makes them worse. Any kludge that last longer
than 3 weeks is permanent. To paraphrase Mills, "How does a system
fail? One kludge at a time."

No comments: