Discussion Locked

Basic SQL (Variable column names)

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have this bit of code:

UPDATE tbl_Legends
SET _1 = '#description#'
WHERE Month = '#month#' and Year = '#year#'

I currently have 31 if statements to make this work. It would be cleaner to use a loop. My trouble is mssql (or coldfusion?) dose not allow the use of a variable name for the column. I would like to do this.

UPDATE tbl_Legends
SET #x# = '#description#'
WHERE Month = '#month#' and Year = '#year#'

I am sure this is somthing easy but I have googled for hours and only find stored procedures as a solution. Any help would be great.

2 replies

by tony hopkinson

and build it inside the loop, is the usual and easy way. Not familliar with cold fusion but if it can't do that I'll be shocked.

by jaqui

cold fusion has support for 75 to 80% of sql, so it can do this.
just as most well known db engines support sql 75 to 80%. none, that I have seen, support it 100% as the actual definitions / standards for sql has more capability than has been required by business.

This discussion is closed to new replies.