Gimme a char. Any char.



  • Found in the CMS that we've recently acquired.
    Suppose you have an 'a'. And then you want a 'b', and then a 'c'. And then a 'd'. Etcetera. And you use these in an SQL query. It's easy! All you have to do is:

    alias = String.fromCharCode( alias.charCodeAt(0) + 1);
    I hope the next version of SQL Server supports "{" as a field name.



  • Does it use those aliases for column names or for table names? In the later case, I would rather worry about the performance of a 27-table-join. Anyway, Oracle allows you to use any characters for names, as long they are enclosed in ". For examples,

    select dummy "whatever U want" from dual;

    is a valid statement. I think SQL Server does the same with [], right? If so, using this alias thingy together with [] might keep you out of trouble for some time...



  • @ammoQ said:

    Does it use those aliases for column names or for table names? In the later case, I would rather worry about the performance of a 27-table-join.



    It does and we are. My DB-coworker cried out WTF when he saw the query in the the error log.

    The conversion to .Net will see a good deal of these WTFs dead.

    I fixed it by writing a string incrementer. As in, zy, zz, baa, bab, bac, bad. So the question becomes: How long can your column names be*? ;)

    *) I don't actually intend to let live a system that generates 5,000,000 char fieldnames.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.