I’m getting the error
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
Here’s my SELECT statement.
SELECT A.vendor_id, **@vendor_employee** = A.vendor_employee_id
, B.txt_first_name, B.txt_last_name,
SELECT txt_Vendor_Employee_Detail_Element,
(CASE
WHEN txt_Vendor_Employee_Detail_Value <> ''
AND txt_Vendor_Employee_Detail_Value IS NOT NULL
THEN txt_Vendor_Employee_Detail_Value
ELSE CONVERT(VARCHAR, txt_Vendor_Employee_Detail_Date)
END) AS Vendor_Detail_Element_Value
FROM t_vendor_employee_detail
WHERE vendor_employee_id = **@vendor_employee**)
FROM...
Yes, basically you can’t return data and assign variables in the same select statement. What I think you intend to do is a
correlated subquerywhich references an outer value.That wolud look something like this:
but you are also returning multiple rows in your subquery which should probably be rewritten as a join.
These examples will give you the basic idea but we would really need the whole query to give you a complete solution.