Reputation:
I'm Using MSsql, I'm wondering if this makes any trouble or can be done different:
Select col1,
(CASE When col2 Like 'abc' Then test + col2 Else col2 END) as col2
from anywhere
Can I rename what I'm doing with col2 to col2 again? it returns no exception at least. Or can this become a problem?
Upvotes: 0
Views: 98
Reputation: 6756
From a technical perspective, the column alias will work. From a debugging and maintenance perspective application-side, someone might be debugging the code, and see a value for "col2". They could then go to the development database and run a query where "col2" equals the value in the debugger (which would be test + col2
), and scratch their head when no records in col2 have the value from the debugger. So it would be best to rename col2 to something useful, to make it clear the result isn't just a raw SELECT of col2.
Upvotes: 0