My client is running MS SQL Server 2000. I completed the project, but I was not able to understand that MS SQL Server 2000 would not allow me to select the internal insert into the values, which gives an error:
Subqueries are not allowed in this context. Only scalar expressions are allowed.
When I run the following query:
insert into table_one (greeting_column, name_column)
values (
'hello',
(select column_1 from table_to where name = 'bob')
)
I call this request from coldfusion10. I already understood the solution using coldFusion10 for this problem, replacing the select statement that caused the query, and storing the results in a coldFusion list variable, then iterating through a loop that inserts the contents of the CF list variable into the corresponding record, but this requires much more processing than a simple statement SQL I found a solution on another webpage that circumvented this issue by doing this (yes, I know that the bad practice of doing “select *” is just an example):
CREATE PROC whatever
@REC int,
@ChangedIP varchar(15),
@ChangedBY varchar(30)
AS
INSERT INTO table_LOG
SELECT *, GETDATE(), @ChangedID, @ChangedBy FROM table WHERE record = @REC
But I don’t think that coldFusion will allow Transact-SQL Variables in the query (it will try after the weekend) Is there a way to overwrite without using Transact-SQL Variables?
source
share