Tuesday, December 16, 2008

SQL code can smell too

I just wrote some bad SQL code tonight that I think I'll have to revisit tomorrow morning when I get back to work.

I think that using a stored procedure to populate an Insert statement is simply wrong. Should anyone modify that stored procedure or change the order in which the values are returned, my insert will fail. Can you smell that? Yeah, it smells bad.

I was simply trying to "encapsulate" things a little and make my code less cluttered. Maybe using a common table expression or temporary table would be a much better idea.

0 comments: