General discussion
Thread display: Collapse - |
All Comments
Start or search
Create a new discussion
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
Basic SQL (Variable column names)
<cfif day eq '_1'>
<cfquery name = "update" dataSource = "KFS">
UPDATE tbl_Legends
SET _1 = '#description#'
WHERE Month = '#month#' and Year = '#year#'
</cfquery>
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.
<cfif day eq #x#>
<cfquery name = "update" dataSource = "KFS">
UPDATE tbl_Legends
SET #x# = '#description#'
WHERE Month = '#month#' and Year = '#year#'
</cfquery>
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.