I am looking for some library that takes the TextWriter approach to writing SQL commands (much like there is the HtmlTextWriter in .Net for writing html). I am NOT writing CRUD-type commands for relational data, I am writing arbitrary SQL (bulk inserts, table creation, creating backups, etc). Any suggestions are appreciated.
Share
I’m not aware of any. I’ve thought about this myself in the past and considered writing one, but decided against it, because I don’t think it really offers much value over and above just writing a plain SQL string. The drawback is, obviously, that it’s harder to read the code and figure out what SQL is being constructed.
XML and HTML have much deeper levels of nesting than (typical) SQL queries. They also have a much more regular structure. That’s why it makes sense to have a class to keep track of that structure. Doing the same in SQL would probably complicate the code more than it would simplify it.